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/util/http_downloader.rs | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'crates/shirabe/src/util/http_downloader.rs') diff --git a/crates/shirabe/src/util/http_downloader.rs b/crates/shirabe/src/util/http_downloader.rs index 18e320c..eeb4b6f 100644 --- a/crates/shirabe/src/util/http_downloader.rs +++ b/crates/shirabe/src/util/http_downloader.rs @@ -14,7 +14,6 @@ use crate::util::StreamContextFactory; use crate::util::Url; use crate::util::http::CurlDownloader; use crate::util::http::Response; -use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; use shirabe_php_shim::{ @@ -215,7 +214,11 @@ impl HttpDownloader { } /// Download a file synchronously - pub fn get(&mut self, url: &str, options: IndexMap) -> Result { + pub fn get( + &mut self, + url: &str, + options: IndexMap, + ) -> anyhow::Result { if self.mock.is_some() { return self.mock_get(url, &options); } @@ -246,7 +249,7 @@ impl HttpDownloader { &mut self, url: &str, options: IndexMap, - ) -> Result { + ) -> anyhow::Result { if self.mock.is_some() { return self.mock_get(url, &options); } @@ -276,7 +279,7 @@ impl HttpDownloader { url: &str, to: &str, options: IndexMap, - ) -> Result { + ) -> anyhow::Result { if self.mock.is_some() { return self.mock_get(url, &options); } @@ -306,7 +309,7 @@ impl HttpDownloader { url: &str, to: &str, options: IndexMap, - ) -> Result { + ) -> anyhow::Result { if self.mock.is_some() { return self.mock_get(url, &options); } @@ -345,7 +348,7 @@ impl HttpDownloader { /// Queues a job and starts it if there is capacity. Mirrors PHP `addJob`: for non-curl (rfs) /// jobs the work runs synchronously here (PHP runs it in the Promise resolver during /// construction); for curl jobs the work is driven later by `start_job` / `count_active_jobs`. - fn add_job(&mut self, mut request: Request, sync: bool) -> Result { + fn add_job(&mut self, mut request: Request, sync: bool) -> anyhow::Result { request.options = array_replace_recursive(self.options.clone(), request.options); let id = self.id_gen; @@ -593,11 +596,11 @@ impl HttpDownloader { /// Wait for current async download jobs to complete /// /// @param int|null $index For internal use only, the job id - pub fn wait(&mut self) -> Result<()> { + pub fn wait(&mut self) -> anyhow::Result<()> { self.wait_id(None) } - fn wait_id(&mut self, index: Option) -> Result<()> { + fn wait_id(&mut self, index: Option) -> anyhow::Result<()> { loop { let job_count = self.count_active_jobs(index)?; if job_count == 0 { @@ -613,7 +616,7 @@ impl HttpDownloader { } /// @internal - pub fn count_active_jobs(&mut self, index: Option) -> Result { + pub fn count_active_jobs(&mut self, index: Option) -> anyhow::Result { if self.running_jobs < self.max_jobs { let queued_ids: Vec = self .jobs @@ -676,7 +679,7 @@ impl HttpDownloader { } /// @param int $index Job id - fn get_response(&mut self, index: i64) -> Result { + fn get_response(&mut self, index: i64) -> anyhow::Result { if !self.jobs.contains_key(&index) { return Err(LogicException { message: "Invalid request id".to_string(), @@ -712,7 +715,7 @@ impl HttpDownloader { io: std::rc::Rc>, url: &str, data: &IndexMap, - ) -> Result<()> { + ) -> anyhow::Result<()> { let clean_message = |msg: &str| -> anyhow::Result { if !io.is_decorated() { return Ok(Preg::replace( @@ -949,7 +952,7 @@ impl HttpDownloader { &mut self, file_url: &str, options: &IndexMap, - ) -> Result { + ) -> anyhow::Result { if file_url.is_empty() { return Err(LogicException { message: "url cannot be an empty string".to_string(), @@ -1019,7 +1022,7 @@ impl HttpDownloader { status: i64, headers: Vec, body: String, - ) -> Result { + ) -> anyhow::Result { if status < 400 { return Ok(Response::new( url.to_string(), -- cgit v1.3.1