diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-29 00:03:00 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-29 00:03:00 +0900 |
| commit | 9be0f98f71fe8071ab839ac1036b4064ac3172b4 (patch) | |
| tree | 66a2f4feba752f4761c40449e0827ad74fc9b02c /crates/shirabe/src/installer | |
| parent | a84d531548efa678d4021cea891826e59f8fb462 (diff) | |
| download | php-shirabe-9be0f98f71fe8071ab839ac1036b4064ac3172b4.tar.gz php-shirabe-9be0f98f71fe8071ab839ac1036b4064ac3172b4.tar.zst php-shirabe-9be0f98f71fe8071ab839ac1036b4064ac3172b4.zip | |
chore(lint): ban bare `use anyhow::Result` and fully qualify it
Add a no_banned_use linter that forbids importing anyhow::Result, and
update all call sites to reference it via its fully-qualified path so
it is never confused with std::result::Result.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/installer')
| -rw-r--r-- | crates/shirabe/src/installer/installation_manager.rs | 61 | ||||
| -rw-r--r-- | crates/shirabe/src/installer/library_installer.rs | 19 | ||||
| -rw-r--r-- | crates/shirabe/src/installer/metapackage_installer.rs | 13 | ||||
| -rw-r--r-- | crates/shirabe/src/installer/plugin_installer.rs | 15 |
4 files changed, 55 insertions, 53 deletions
diff --git a/crates/shirabe/src/installer/installation_manager.rs b/crates/shirabe/src/installer/installation_manager.rs index c1e65a8..97e1985 100644 --- a/crates/shirabe/src/installer/installation_manager.rs +++ b/crates/shirabe/src/installer/installation_manager.rs @@ -18,7 +18,6 @@ use crate::repository::InstalledRepositoryInterface; use crate::util::Platform; use crate::util::r#loop::Loop; use crate::util::sync_executor; -use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::seld::signal::SignalHandler; use shirabe_php_shim::{ @@ -156,7 +155,7 @@ impl InstallationManager { } /// Returns installer for a specific package type. - pub fn get_installer(&mut self, r#type: &str) -> Result<&mut dyn InstallerInterface> { + pub fn get_installer(&mut self, r#type: &str) -> anyhow::Result<&mut dyn InstallerInterface> { let r#type = strtolower(r#type); if let Some(&index) = self.cache.get(&r#type) { @@ -184,7 +183,7 @@ impl InstallationManager { &mut self, repo: &dyn InstalledRepositoryInterface, package: PackageInterfaceHandle, - ) -> Result<bool> { + ) -> anyhow::Result<bool> { // For testing only (ref InstallationManagerMock::isPackageInstalled). if self.mock.is_some() { return Ok(repo.has_package(package)); @@ -228,7 +227,7 @@ impl InstallationManager { dev_mode: bool, run_scripts: bool, download_only: bool, - ) -> Result<()> { + ) -> anyhow::Result<()> { // For testing only: the mock records each operation and mutates the repo directly, // skipping the download step (ref InstallationManagerMock::execute). The alias operations' // repo mutation is inlined (rather than calling mark_alias_*) so `self.mock` can stay @@ -297,8 +296,9 @@ impl InstallationManager { let mut cleanup_promises: IndexMap< i64, Box< - dyn Fn() - -> Option<std::pin::Pin<Box<dyn std::future::Future<Output = Result<()>>>>>, + dyn Fn() -> Option< + std::pin::Pin<Box<dyn std::future::Future<Output = anyhow::Result<()>>>>, + >, >, > = IndexMap::new(); @@ -318,7 +318,7 @@ impl InstallationManager { let all_operations: Vec<std::rc::Rc<dyn OperationInterface>> = operations.clone(); - let result: Result<()> = (|| -> Result<()> { + let result: anyhow::Result<()> = (|| -> anyhow::Result<()> { // execute operations in batches to make sure download-modifying-plugins are installed // before the other packages get downloaded let mut batches: Vec<IndexMap<i64, std::rc::Rc<dyn OperationInterface>>> = vec![]; @@ -405,15 +405,16 @@ impl InstallationManager { cleanup_promises: &mut IndexMap< i64, Box< - dyn Fn() - -> Option<std::pin::Pin<Box<dyn std::future::Future<Output = Result<()>>>>>, + dyn Fn() -> Option< + std::pin::Pin<Box<dyn std::future::Future<Output = anyhow::Result<()>>>>, + >, >, >, dev_mode: bool, run_scripts: bool, download_only: bool, all_operations: Vec<std::rc::Rc<dyn OperationInterface>>, - ) -> Result<()> { + ) -> anyhow::Result<()> { for (index, operation) in &operations { let op_type = operation.get_operation_type(); @@ -449,8 +450,9 @@ impl InstallationManager { let _ = installer; let op_type_clone = op_type.clone(); let cleanup: Box< - dyn Fn() - -> Option<std::pin::Pin<Box<dyn std::future::Future<Output = Result<()>>>>>, + dyn Fn() -> Option< + std::pin::Pin<Box<dyn std::future::Future<Output = anyhow::Result<()>>>>, + >, > = Box::new(move || { // avoid calling cleanup if the download was not even initialized for a package // as without installation source configured nothing will work @@ -458,7 +460,7 @@ impl InstallationManager { let _ = &op_type_clone; // TODO(phase-c-promise): build the real installer.cleanup() future once the installer // can be shared into a 'static cleanup closure (Stage 2 Rc/Arc). - let fut: std::pin::Pin<Box<dyn std::future::Future<Output = Result<()>>>> = + let fut: std::pin::Pin<Box<dyn std::future::Future<Output = anyhow::Result<()>>>> = Box::pin(async { Ok(()) }); Some(fut) }); @@ -533,14 +535,15 @@ impl InstallationManager { cleanup_promises: &IndexMap< i64, Box< - dyn Fn() - -> Option<std::pin::Pin<Box<dyn std::future::Future<Output = Result<()>>>>>, + dyn Fn() -> Option< + std::pin::Pin<Box<dyn std::future::Future<Output = anyhow::Result<()>>>>, + >, >, >, dev_mode: bool, run_scripts: bool, all_operations: &[std::rc::Rc<dyn OperationInterface>], - ) -> Result<()> { + ) -> anyhow::Result<()> { let mut post_exec_callbacks: Vec<Box<dyn Fn()>> = vec![]; for (index, operation) in operations { @@ -711,7 +714,7 @@ impl InstallationManager { &mut self, repo: &mut dyn InstalledRepositoryInterface, operation: &InstallOperation, - ) -> Result<Option<PhpMixed>> { + ) -> anyhow::Result<Option<PhpMixed>> { let package = operation.get_package(); let package_type = package.get_type(); let installer = self.get_installer(&package_type)?; @@ -726,7 +729,7 @@ impl InstallationManager { &mut self, repo: &mut dyn InstalledRepositoryInterface, operation: &UpdateOperation, - ) -> Result<Option<PhpMixed>> { + ) -> anyhow::Result<Option<PhpMixed>> { let initial = operation.get_initial_package().clone(); let target = operation.get_target_package().clone(); @@ -754,7 +757,7 @@ impl InstallationManager { &mut self, repo: &mut dyn InstalledRepositoryInterface, operation: &UninstallOperation, - ) -> Result<Option<PhpMixed>> { + ) -> anyhow::Result<Option<PhpMixed>> { let package = operation.get_package(); let package_type = package.get_type(); let installer = self.get_installer(&package_type)?; @@ -810,7 +813,7 @@ impl InstallationManager { // TODO(phase-c-promise): PHP collects every http_downloader.add() promise and runs them via // Loop::wait; the single-threaded sync bridge block_on's each notification serially instead. - let result: Result<()> = (|| -> Result<()> { + let result: anyhow::Result<()> = (|| -> anyhow::Result<()> { for (repo_url, packages) in &self.notifiable_packages { // non-batch API, deprecated if str_contains(repo_url, "%package%") { @@ -937,13 +940,15 @@ impl InstallationManager { cleanup_promises: &IndexMap< i64, Box< - dyn Fn() - -> Option<std::pin::Pin<Box<dyn std::future::Future<Output = Result<()>>>>>, + dyn Fn() -> Option< + std::pin::Pin<Box<dyn std::future::Future<Output = anyhow::Result<()>>>>, + >, >, >, ) { - let mut promises: Vec<std::pin::Pin<Box<dyn std::future::Future<Output = Result<()>>>>> = - vec![]; + let mut promises: Vec< + std::pin::Pin<Box<dyn std::future::Future<Output = anyhow::Result<()>>>>, + > = vec![]; self.loop_.borrow().abort_jobs(); @@ -980,7 +985,7 @@ pub trait InstallationManagerInterface: std::fmt::Debug { &mut self, repo: &dyn InstalledRepositoryInterface, package: PackageInterfaceHandle, - ) -> Result<bool>; + ) -> anyhow::Result<bool>; fn ensure_binaries_presence(&mut self, package: PackageInterfaceHandle); fn execute( &mut self, @@ -989,7 +994,7 @@ pub trait InstallationManagerInterface: std::fmt::Debug { dev_mode: bool, run_scripts: bool, download_only: bool, - ) -> Result<()>; + ) -> anyhow::Result<()>; fn get_install_path(&mut self, package: PackageInterfaceHandle) -> Option<String>; fn set_output_progress(&mut self, output_progress: bool); fn notify_installs(&mut self, io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>); @@ -1016,7 +1021,7 @@ impl InstallationManagerInterface for InstallationManager { &mut self, repo: &dyn InstalledRepositoryInterface, package: PackageInterfaceHandle, - ) -> Result<bool> { + ) -> anyhow::Result<bool> { self.is_package_installed(repo, package) } @@ -1031,7 +1036,7 @@ impl InstallationManagerInterface for InstallationManager { dev_mode: bool, run_scripts: bool, download_only: bool, - ) -> Result<()> { + ) -> anyhow::Result<()> { self.execute(repo, operations, dev_mode, run_scripts, download_only) } diff --git a/crates/shirabe/src/installer/library_installer.rs b/crates/shirabe/src/installer/library_installer.rs index 133ba7c..c0b2ebc 100644 --- a/crates/shirabe/src/installer/library_installer.rs +++ b/crates/shirabe/src/installer/library_installer.rs @@ -12,7 +12,6 @@ use crate::repository::InstalledRepositoryInterface; use crate::util::Filesystem; use crate::util::Platform; use crate::util::Silencer; -use anyhow::Result; use shirabe_external_packages::composer::pcre::Preg; use shirabe_php_shim::{ InvalidArgumentException, LogicException, PhpMixed, dirname, is_dir, is_link, preg_quote, @@ -146,7 +145,7 @@ impl LibraryInstaller { pub(crate) async fn install_code( &mut self, package: PackageInterfaceHandle, - ) -> Result<Option<PhpMixed>> { + ) -> anyhow::Result<Option<PhpMixed>> { let download_path = self.get_install_path(package.clone()).unwrap(); self.get_download_manager() @@ -161,7 +160,7 @@ impl LibraryInstaller { &mut self, initial: PackageInterfaceHandle, target: PackageInterfaceHandle, - ) -> Result<Option<PhpMixed>> { + ) -> anyhow::Result<Option<PhpMixed>> { let initial_download_path = self.get_install_path(initial.clone()).unwrap(); let target_download_path = self.get_install_path(target.clone()).unwrap(); if target_download_path != initial_download_path { @@ -191,7 +190,7 @@ impl LibraryInstaller { pub(crate) async fn remove_code( &mut self, package: PackageInterfaceHandle, - ) -> Result<Option<PhpMixed>> { + ) -> anyhow::Result<Option<PhpMixed>> { let download_path = self.get_package_base_path(package.clone()); self.get_download_manager() @@ -271,7 +270,7 @@ impl InstallerInterface for LibraryInstaller { &mut self, package: PackageInterfaceHandle, prev_package: Option<PackageInterfaceHandle>, - ) -> Result<Option<PhpMixed>> { + ) -> anyhow::Result<Option<PhpMixed>> { self.initialize_vendor_dir(); let download_path = self.get_install_path(package.clone()).unwrap(); @@ -286,7 +285,7 @@ impl InstallerInterface for LibraryInstaller { r#type: &str, package: PackageInterfaceHandle, prev_package: Option<PackageInterfaceHandle>, - ) -> Result<Option<PhpMixed>> { + ) -> anyhow::Result<Option<PhpMixed>> { self.initialize_vendor_dir(); let download_path = self.get_install_path(package.clone()).unwrap(); @@ -301,7 +300,7 @@ impl InstallerInterface for LibraryInstaller { r#type: &str, package: PackageInterfaceHandle, prev_package: Option<PackageInterfaceHandle>, - ) -> Result<Option<PhpMixed>> { + ) -> anyhow::Result<Option<PhpMixed>> { self.initialize_vendor_dir(); let download_path = self.get_install_path(package.clone()).unwrap(); @@ -315,7 +314,7 @@ impl InstallerInterface for LibraryInstaller { &mut self, repo: &mut dyn InstalledRepositoryInterface, package: PackageInterfaceHandle, - ) -> Result<Option<PhpMixed>> { + ) -> anyhow::Result<Option<PhpMixed>> { self.initialize_vendor_dir(); let download_path = self.get_install_path(package.clone()).unwrap(); @@ -344,7 +343,7 @@ impl InstallerInterface for LibraryInstaller { repo: &mut dyn InstalledRepositoryInterface, initial: PackageInterfaceHandle, target: PackageInterfaceHandle, - ) -> Result<Option<PhpMixed>> { + ) -> anyhow::Result<Option<PhpMixed>> { if !repo.has_package(initial.clone()) { return Err(InvalidArgumentException { message: format!("Package is not installed: {}", initial), @@ -376,7 +375,7 @@ impl InstallerInterface for LibraryInstaller { &mut self, repo: &mut dyn InstalledRepositoryInterface, package: PackageInterfaceHandle, - ) -> Result<Option<PhpMixed>> { + ) -> anyhow::Result<Option<PhpMixed>> { if !repo.has_package(package.clone()) { return Err(InvalidArgumentException { message: format!("Package is not installed: {}", package), diff --git a/crates/shirabe/src/installer/metapackage_installer.rs b/crates/shirabe/src/installer/metapackage_installer.rs index cebec2c..ae1f49b 100644 --- a/crates/shirabe/src/installer/metapackage_installer.rs +++ b/crates/shirabe/src/installer/metapackage_installer.rs @@ -9,7 +9,6 @@ use crate::io::IOInterfaceImmutable; use crate::io::io_interface; use crate::package::PackageInterfaceHandle; use crate::repository::InstalledRepositoryInterface; -use anyhow::Result; use shirabe_php_shim::{InvalidArgumentException, PhpMixed}; #[derive(Debug)] @@ -41,7 +40,7 @@ impl InstallerInterface for MetapackageInstaller { &mut self, _package: PackageInterfaceHandle, _prev_package: Option<PackageInterfaceHandle>, - ) -> Result<Option<PhpMixed>> { + ) -> anyhow::Result<Option<PhpMixed>> { Ok(None) } @@ -50,7 +49,7 @@ impl InstallerInterface for MetapackageInstaller { _type: &str, _package: PackageInterfaceHandle, _prev_package: Option<PackageInterfaceHandle>, - ) -> Result<Option<PhpMixed>> { + ) -> anyhow::Result<Option<PhpMixed>> { Ok(None) } @@ -59,7 +58,7 @@ impl InstallerInterface for MetapackageInstaller { _type: &str, _package: PackageInterfaceHandle, _prev_package: Option<PackageInterfaceHandle>, - ) -> Result<Option<PhpMixed>> { + ) -> anyhow::Result<Option<PhpMixed>> { Ok(None) } @@ -67,7 +66,7 @@ impl InstallerInterface for MetapackageInstaller { &mut self, repo: &mut dyn InstalledRepositoryInterface, package: PackageInterfaceHandle, - ) -> Result<Option<PhpMixed>> { + ) -> anyhow::Result<Option<PhpMixed>> { self.io.write_error3( &format!(" - {}", InstallOperation::format(package.clone(), false)), true, @@ -84,7 +83,7 @@ impl InstallerInterface for MetapackageInstaller { repo: &mut dyn InstalledRepositoryInterface, initial: PackageInterfaceHandle, target: PackageInterfaceHandle, - ) -> Result<Option<PhpMixed>> { + ) -> anyhow::Result<Option<PhpMixed>> { if !repo.has_package(initial.clone()) { return Err(InvalidArgumentException { message: format!("Package is not installed: {}", initial), @@ -112,7 +111,7 @@ impl InstallerInterface for MetapackageInstaller { &mut self, repo: &mut dyn InstalledRepositoryInterface, package: PackageInterfaceHandle, - ) -> Result<Option<PhpMixed>> { + ) -> anyhow::Result<Option<PhpMixed>> { if !repo.has_package(package.clone()) { return Err(InvalidArgumentException { message: format!("Package is not installed: {}", package), diff --git a/crates/shirabe/src/installer/plugin_installer.rs b/crates/shirabe/src/installer/plugin_installer.rs index 28e4e0d..132d408 100644 --- a/crates/shirabe/src/installer/plugin_installer.rs +++ b/crates/shirabe/src/installer/plugin_installer.rs @@ -11,7 +11,6 @@ use crate::plugin::PluginManager; use crate::repository::InstalledRepositoryInterface; use crate::util::Filesystem; use crate::util::Platform; -use anyhow::Result; use shirabe_php_shim::{PhpMixed, UnexpectedValueException, empty}; #[derive(Debug)] @@ -49,7 +48,7 @@ impl PluginInstaller { e: anyhow::Error, repo: &mut dyn InstalledRepositoryInterface, package: PackageInterfaceHandle, - ) -> Result<()> { + ) -> anyhow::Result<()> { self.inner.io.write_error(&format!( "Plugin initialization failed ({}), uninstalling plugin", e @@ -83,7 +82,7 @@ impl InstallerInterface for PluginInstaller { r#type: &str, package: PackageInterfaceHandle, prev_package: Option<PackageInterfaceHandle>, - ) -> Result<Option<PhpMixed>> { + ) -> anyhow::Result<Option<PhpMixed>> { if (r#type == "install" || r#type == "update") && !self .get_plugin_manager() @@ -110,7 +109,7 @@ impl InstallerInterface for PluginInstaller { &mut self, package: PackageInterfaceHandle, prev_package: Option<PackageInterfaceHandle>, - ) -> Result<Option<PhpMixed>> { + ) -> anyhow::Result<Option<PhpMixed>> { let extra = package.get_extra(); let class = extra.get("class").cloned().unwrap_or(PhpMixed::Null); if empty(&class) { @@ -130,7 +129,7 @@ impl InstallerInterface for PluginInstaller { &mut self, repo: &mut dyn InstalledRepositoryInterface, package: PackageInterfaceHandle, - ) -> Result<Option<PhpMixed>> { + ) -> anyhow::Result<Option<PhpMixed>> { self.inner.install(repo, package).await?; // TODO(plugin): register package in plugin manager after install, rollback on failure @@ -145,7 +144,7 @@ impl InstallerInterface for PluginInstaller { repo: &mut dyn InstalledRepositoryInterface, initial: PackageInterfaceHandle, target: PackageInterfaceHandle, - ) -> Result<Option<PhpMixed>> { + ) -> anyhow::Result<Option<PhpMixed>> { self.inner.update(repo, initial, target).await?; // TODO(plugin): deactivate initial and register target in plugin manager after update, rollback on failure @@ -160,7 +159,7 @@ impl InstallerInterface for PluginInstaller { &mut self, repo: &mut dyn InstalledRepositoryInterface, package: PackageInterfaceHandle, - ) -> Result<Option<PhpMixed>> { + ) -> anyhow::Result<Option<PhpMixed>> { // TODO(plugin): uninstall package from plugin manager self.get_plugin_manager() .borrow_mut() @@ -174,7 +173,7 @@ impl InstallerInterface for PluginInstaller { r#type: &str, package: PackageInterfaceHandle, prev_package: Option<PackageInterfaceHandle>, - ) -> Result<Option<PhpMixed>> { + ) -> anyhow::Result<Option<PhpMixed>> { self.inner.cleanup(r#type, package, prev_package).await } |
