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/no_proxy_pattern.rs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'crates/shirabe/src/util/no_proxy_pattern.rs') diff --git a/crates/shirabe/src/util/no_proxy_pattern.rs b/crates/shirabe/src/util/no_proxy_pattern.rs index 3715ea9..0a3d564 100644 --- a/crates/shirabe/src/util/no_proxy_pattern.rs +++ b/crates/shirabe/src/util/no_proxy_pattern.rs @@ -1,6 +1,5 @@ //! ref: composer/src/Composer/Util/NoProxyPattern.php -use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::Preg; use shirabe_php_shim::{ @@ -49,7 +48,7 @@ impl NoProxyPattern { } /// Returns true if a URL matches the NO_PROXY pattern - pub fn test(&mut self, url: &str) -> Result { + pub fn test(&mut self, url: &str) -> anyhow::Result { if self.noproxy { return Ok(true); } @@ -72,7 +71,7 @@ impl NoProxyPattern { /// Returns false is the url cannot be parsed, otherwise a data object /// /// @return bool|stdClass - pub(crate) fn get_url_data(&self, url: &str) -> Result> { + pub(crate) fn get_url_data(&self, url: &str) -> anyhow::Result> { let host = parse_url(url, PHP_URL_HOST); if empty(&host) { return Ok(None); @@ -110,7 +109,12 @@ impl NoProxyPattern { } /// Returns true if the url is matched by a rule - pub(crate) fn r#match(&mut self, index: i64, host_name: &str, url: &UrlData) -> Result { + pub(crate) fn r#match( + &mut self, + index: i64, + host_name: &str, + url: &UrlData, + ) -> anyhow::Result { let rule = match self.get_rule(index, host_name)? { Some(r) => r, None => { @@ -146,7 +150,7 @@ impl NoProxyPattern { } /// Returns true if the target ip is in the network range - pub(crate) fn match_range(&self, network: &IpData, target: &IpData) -> Result { + pub(crate) fn match_range(&self, network: &IpData, target: &IpData) -> anyhow::Result { let net = unpack("C*", &network.ip); let mask = unpack("C*", network.netmask.as_deref().unwrap_or_default()); let ip = unpack("C*", &target.ip); @@ -212,7 +216,7 @@ impl NoProxyPattern { /// Finds or creates rule data for a hostname /// /// @return null|stdClass Null if the hostname is invalid - fn get_rule(&mut self, index: i64, host_name: &str) -> Result> { + fn get_rule(&mut self, index: i64, host_name: &str) -> anyhow::Result> { if array_key_exists(&index.to_string(), &{ let mut m: IndexMap = IndexMap::new(); for k in self.rules.keys() { @@ -248,7 +252,7 @@ impl NoProxyPattern { host: &str, ipdata: &mut Option, allow_prefix: bool, - ) -> Result { + ) -> anyhow::Result { *ipdata = None; let mut netmask: Option> = None; let mut prefix: Option = None; @@ -345,7 +349,7 @@ impl NoProxyPattern { range_ip: &[u8], size: i64, prefix: i64, - ) -> Result<(Vec, Vec)> { + ) -> anyhow::Result<(Vec, Vec)> { let netmask = self.ip_get_mask(prefix, size); // Get the network from the address and mask @@ -435,7 +439,7 @@ impl NoProxyPattern { /// Splits the hostname into host and port components /// /// @return mixed[] host, port, if there was error - fn split_host_port(&self, host_name: &str) -> Result<(String, i64, bool)> { + fn split_host_port(&self, host_name: &str) -> anyhow::Result<(String, i64, bool)> { // host, port, err let error = (String::new(), 0_i64, true); let mut port: i64 = 0; -- cgit v1.3.1