From 9be0f98f71fe8071ab839ac1036b4064ac3172b4 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 29 Jun 2026 00:03:00 +0900 Subject: 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) --- crates/shirabe/src/command/base_command.rs | 45 +++++++++++++++++------------- 1 file changed, 25 insertions(+), 20 deletions(-) (limited to 'crates/shirabe/src/command/base_command.rs') diff --git a/crates/shirabe/src/command/base_command.rs b/crates/shirabe/src/command/base_command.rs index 46ee5f7..25618c5 100644 --- a/crates/shirabe/src/command/base_command.rs +++ b/crates/shirabe/src/command/base_command.rs @@ -17,7 +17,6 @@ use crate::package::version::VersionParser; use crate::plugin::PluginEvents; use crate::plugin::PreCommandRunEvent; use crate::util::Platform; -use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::symfony::console::Terminal; use shirabe_external_packages::symfony::console::command::command::{ @@ -139,7 +138,7 @@ pub trait BaseCommand: Command { &self, disable_plugins: Option, disable_scripts: Option, - ) -> Result; + ) -> anyhow::Result; /// Retrieves the default Composer\Composer instance or null fn try_composer( @@ -151,7 +150,7 @@ pub trait BaseCommand: Command { fn set_composer(&self, composer: PartialComposerHandle); /// Removes the cached composer instance - fn reset_composer(&self) -> Result<()>; + fn reset_composer(&self) -> anyhow::Result<()>; fn get_io(&self) -> Rc>; @@ -165,7 +164,7 @@ pub trait BaseCommand: Command { config: Option>, disable_plugins: bool, disable_scripts: Option, - ) -> Result; + ) -> anyhow::Result; /// Returns preferSource and preferDist values based on the configuration. fn get_preferred_install_options( @@ -173,17 +172,20 @@ pub trait BaseCommand: Command { config: &Config, input: Rc>, keep_vcs_requires_prefer_source: bool, - ) -> Result<(bool, bool)>; + ) -> anyhow::Result<(bool, bool)>; fn get_platform_requirement_filter( &self, input: Rc>, - ) -> Result>; + ) -> anyhow::Result>; /// @param array $requirements /// /// @return array - fn format_requirements(&self, requirements: Vec) -> Result>; + fn format_requirements( + &self, + requirements: Vec, + ) -> anyhow::Result>; /// @param array $requirements /// @@ -191,7 +193,7 @@ pub trait BaseCommand: Command { fn normalize_requirements( &self, requirements: Vec, - ) -> Result>>; + ) -> anyhow::Result>>; /// @param array $table fn render_table(&self, table: Vec, output: Rc>); @@ -205,14 +207,14 @@ pub trait BaseCommand: Command { &self, input: Rc>, opt_name: &str, - ) -> Result; + ) -> anyhow::Result; /// Creates an AuditConfig from the Config object, optionally overriding security blocking based on input options fn create_audit_config( &self, config: &mut Config, input: Rc>, - ) -> Result; + ) -> anyhow::Result; } /// Forwards every Composer-specific `BaseCommand` method that no command overrides to an @@ -253,7 +255,7 @@ impl BaseCommand for BaseCommandData { &self, disable_plugins: Option, disable_scripts: Option, - ) -> Result { + ) -> anyhow::Result { if self.composer.borrow().is_none() { let application = self.get_application(); let Some(application) = application else { @@ -311,7 +313,7 @@ impl BaseCommand for BaseCommandData { *self.composer.borrow_mut() = Some(composer); } - fn reset_composer(&self) -> Result<()> { + fn reset_composer(&self) -> anyhow::Result<()> { *self.composer.borrow_mut() = None; if let Some(application) = self.get_application() { let mut app_ref = application.borrow_mut(); @@ -360,7 +362,7 @@ impl BaseCommand for BaseCommandData { config: Option>, disable_plugins: bool, disable_scripts: Option, - ) -> Result { + ) -> anyhow::Result { let disable_plugins = disable_plugins || input .borrow() @@ -388,7 +390,7 @@ impl BaseCommand for BaseCommandData { config: &Config, input: Rc>, keep_vcs_requires_prefer_source: bool, - ) -> Result<(bool, bool)> { + ) -> anyhow::Result<(bool, bool)> { let mut prefer_source = false; let mut prefer_dist = false; @@ -510,7 +512,7 @@ impl BaseCommand for BaseCommandData { fn get_platform_requirement_filter( &self, input: Rc>, - ) -> Result> { + ) -> anyhow::Result> { if !input.borrow().has_option("ignore-platform-reqs") || !input.borrow().has_option("ignore-platform-req") { @@ -540,7 +542,10 @@ impl BaseCommand for BaseCommandData { Ok(PlatformRequirementFilterFactory::ignore_nothing()) } - fn format_requirements(&self, requirements: Vec) -> Result> { + fn format_requirements( + &self, + requirements: Vec, + ) -> anyhow::Result> { let mut requires: IndexMap = IndexMap::new(); let requirements = self.normalize_requirements(requirements)?; for requirement in requirements { @@ -567,7 +572,7 @@ impl BaseCommand for BaseCommandData { fn normalize_requirements( &self, requirements: Vec, - ) -> Result>> { + ) -> anyhow::Result>> { let parser: VersionParser = VersionParser::new(); parser.parse_name_version_pairs(requirements) @@ -602,7 +607,7 @@ impl BaseCommand for BaseCommandData { &self, input: Rc>, opt_name: &str, - ) -> Result { + ) -> anyhow::Result { if !input.borrow().has_option(opt_name) { return Err(LogicException { message: format!( @@ -638,7 +643,7 @@ impl BaseCommand for BaseCommandData { &self, config: &mut Config, input: Rc>, - ) -> Result { + ) -> anyhow::Result { // Handle both --audit and --no-audit flags let audit = if input.borrow().has_option("audit") { input @@ -700,7 +705,7 @@ pub fn base_command_initialize( cmd: &dyn BaseCommand, input: Rc>, _output: Rc>, -) -> Result<()> { +) -> anyhow::Result<()> { // initialize a plugin-enabled Composer instance, either local or global // PHP also ORs in $this->getApplication()->getDisablePluginsByDefault() / // getDisableScriptsByDefault(). -- cgit v1.3.1