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/downloader/file_downloader.rs | 29 +++++++++++++++--------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'crates/shirabe/src/downloader/file_downloader.rs') diff --git a/crates/shirabe/src/downloader/file_downloader.rs b/crates/shirabe/src/downloader/file_downloader.rs index a6334fb..6286918 100644 --- a/crates/shirabe/src/downloader/file_downloader.rs +++ b/crates/shirabe/src/downloader/file_downloader.rs @@ -24,7 +24,6 @@ use crate::util::ProcessExecutor; use crate::util::Silencer; use crate::util::Url as UrlUtil; use crate::util::sync_executor; -use anyhow::Result; use indexmap::IndexMap; use shirabe_php_shim::{ DIRECTORY_SEPARATOR, InvalidArgumentException, PATHINFO_BASENAME, PATHINFO_EXTENSION, @@ -162,7 +161,7 @@ impl DownloaderInterface for FileDownloader { path: &str, _prev_package: Option, output: bool, - ) -> Result> { + ) -> anyhow::Result> { if package.get_dist_url().is_none() { return Err(InvalidArgumentException { message: "The given package is missing url information".to_string(), @@ -439,7 +438,7 @@ impl DownloaderInterface for FileDownloader { _package: PackageInterfaceHandle, _path: &str, _prev_package: Option, - ) -> Result> { + ) -> anyhow::Result> { Ok(Some(PhpMixed::Null)) } @@ -450,7 +449,7 @@ impl DownloaderInterface for FileDownloader { package: PackageInterfaceHandle, path: &str, _prev_package: Option, - ) -> Result> { + ) -> anyhow::Result> { let file_name = self.get_file_name(package.clone(), path); if file_exists(&file_name) { self.filesystem.borrow_mut().unlink(&file_name)?; @@ -504,7 +503,7 @@ impl DownloaderInterface for FileDownloader { package: PackageInterfaceHandle, path: &str, output: bool, - ) -> Result> { + ) -> anyhow::Result> { if output { self.io.write_error(&format!( " - {}", @@ -561,7 +560,7 @@ impl DownloaderInterface for FileDownloader { initial: PackageInterfaceHandle, target: PackageInterfaceHandle, path: &str, - ) -> Result> { + ) -> anyhow::Result> { self.io.write_error(&format!( " - {}{}", UpdateOperation::format(initial.clone(), target.clone(), false), @@ -579,7 +578,7 @@ impl DownloaderInterface for FileDownloader { package: PackageInterfaceHandle, path: &str, output: bool, - ) -> Result> { + ) -> anyhow::Result> { if output { self.io.write_error(&format!( " - {}", @@ -610,7 +609,7 @@ impl ChangeReportInterface for FileDownloader { &mut self, package: PackageInterfaceHandle, path: &str, - ) -> Result> { + ) -> anyhow::Result> { let prev_io = std::mem::replace( &mut self.io, std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())), @@ -623,7 +622,7 @@ impl ChangeReportInterface for FileDownloader { // PHP attaches an onRejected handler to capture the error and drives the promise via // httpDownloader->wait() / process->wait(); the single-threaded sync bridge block_on's the // download/install futures, so a rejection surfaces directly as the Err captured below. - let result: Result = (|| -> Result { + let result: anyhow::Result = (|| -> anyhow::Result { if is_dir(format!("{}_compare", target_dir)) { self.filesystem .borrow_mut() @@ -773,12 +772,20 @@ impl FileDownloader { } /// For testing only: invoke the crate-private `process_url`. - pub fn __process_url(&self, package: PackageInterfaceHandle, url: &str) -> Result { + pub fn __process_url( + &self, + package: PackageInterfaceHandle, + url: &str, + ) -> anyhow::Result { self.process_url(package, url) } /// Process the download url - pub(crate) fn process_url(&self, package: PackageInterfaceHandle, url: &str) -> Result { + pub(crate) fn process_url( + &self, + package: PackageInterfaceHandle, + url: &str, + ) -> anyhow::Result { if !shirabe_php_shim::extension_loaded("openssl") && Some(0) == strpos(url, "https:") { return Err(RuntimeException { message: "You must enable the openssl extension to download files via https" -- cgit v1.3.1