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) --- .../shirabe/src/package/version/version_bumper.rs | 3 +-- .../shirabe/src/package/version/version_guesser.rs | 27 +++++++++++----------- 2 files changed, 14 insertions(+), 16 deletions(-) (limited to 'crates/shirabe/src/package/version') diff --git a/crates/shirabe/src/package/version/version_bumper.rs b/crates/shirabe/src/package/version/version_bumper.rs index 4deb450..4f2d324 100644 --- a/crates/shirabe/src/package/version/version_bumper.rs +++ b/crates/shirabe/src/package/version/version_bumper.rs @@ -5,7 +5,6 @@ use crate::package::dumper::ArrayDumper; use crate::package::loader::ArrayLoader; use crate::package::version::VersionParser; use crate::util::Platform; -use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; use shirabe_semver::Intervals; @@ -19,7 +18,7 @@ impl VersionBumper { &self, constraint: &AnyConstraint, package: PackageInterfaceHandle, - ) -> Result { + ) -> anyhow::Result { let parser = VersionParser::new(); let pretty_constraint = constraint.get_pretty_string(); if pretty_constraint.starts_with("dev-") { diff --git a/crates/shirabe/src/package/version/version_guesser.rs b/crates/shirabe/src/package/version/version_guesser.rs index 6fba7c4..249646c 100644 --- a/crates/shirabe/src/package/version/version_guesser.rs +++ b/crates/shirabe/src/package/version/version_guesser.rs @@ -11,7 +11,6 @@ use crate::util::Platform; use crate::util::ProcessExecutor; use crate::util::Svn as SvnUtil; use crate::util::sync_executor; -use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; use shirabe_php_shim::{ @@ -28,9 +27,9 @@ pub trait VersionGuesserInterface: std::fmt::Debug { &mut self, package_config: &IndexMap, path: &str, - ) -> Result>; + ) -> anyhow::Result>; - fn get_root_version_from_env(&self) -> Result; + fn get_root_version_from_env(&self) -> anyhow::Result; } /// Try to guess the current version number based on different VCS configuration. @@ -103,7 +102,7 @@ impl VersionGuesser { &mut self, package_config: &IndexMap, path: &str, - ) -> Result> { + ) -> anyhow::Result> { // For testing only (ref VersionGuesserMock::guessVersion returns null). if self.mock { return Ok(None); @@ -207,7 +206,7 @@ impl VersionGuesser { &mut self, package_config: &IndexMap, path: &str, - ) -> Result { + ) -> anyhow::Result { GitUtil::clean_env(&self.process); let mut commit: Option = None; let mut version: Option = None; @@ -365,7 +364,7 @@ impl VersionGuesser { } /// @return array{version: string, pretty_version: string}|null - fn version_from_git_tags(&mut self, path: &str) -> Result> { + fn version_from_git_tags(&mut self, path: &str) -> anyhow::Result> { // try to fetch current version from git tags let mut output = String::new(); if 0 == self.process.borrow_mut().execute_args( @@ -394,7 +393,7 @@ impl VersionGuesser { &mut self, package_config: &IndexMap, path: &str, - ) -> Result> { + ) -> anyhow::Result> { // try to fetch current version from hg branch let mut output = String::new(); if 0 == self.process.borrow_mut().execute_args( @@ -492,7 +491,7 @@ impl VersionGuesser { mut branches: Vec, scm_cmdline: Vec, path: &str, - ) -> Result { + ) -> anyhow::Result { let mut pretty_version: Option = version.clone(); let mut version = version; @@ -546,7 +545,7 @@ impl VersionGuesser { // PHP runs every candidate diff in parallel and cancels the siblings once a zero-length // diff is found; the single-threaded sync bridge block_on's each diff serially and stops // at the first zero-length match. - let result: Result<()> = (|| -> Result<()> { + let result: anyhow::Result<()> = (|| -> anyhow::Result<()> { let mut last_index: i64 = -1; for (index, candidate) in branches.iter().enumerate() { let index = index as i64; @@ -635,7 +634,7 @@ impl VersionGuesser { } /// @return array{version: string|null, commit: '', pretty_version: string|null} - fn guess_fossil_version(&mut self, path: &str) -> Result { + fn guess_fossil_version(&mut self, path: &str) -> anyhow::Result { let mut version: Option = None; let mut pretty_version: Option = None; @@ -687,7 +686,7 @@ impl VersionGuesser { &mut self, package_config: &IndexMap, path: &str, - ) -> Result> { + ) -> anyhow::Result> { SvnUtil::clean_env(); // try to fetch current version from svn @@ -760,7 +759,7 @@ impl VersionGuesser { Ok(None) } - pub fn get_root_version_from_env(&self) -> Result { + pub fn get_root_version_from_env(&self) -> anyhow::Result { let version = Platform::get_env("COMPOSER_ROOT_VERSION"); let version = match version { Some(v) if !v.is_empty() => v, @@ -789,11 +788,11 @@ impl VersionGuesserInterface for VersionGuesser { &mut self, package_config: &IndexMap, path: &str, - ) -> Result> { + ) -> anyhow::Result> { VersionGuesser::guess_version(self, package_config, path) } - fn get_root_version_from_env(&self) -> Result { + fn get_root_version_from_env(&self) -> anyhow::Result { VersionGuesser::get_root_version_from_env(self) } } -- cgit v1.3.1