From 42bf1196003c0b39179d8c9d2c07ecf9a83a4a74 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Wed, 7 Jan 2026 17:16:37 +0000 Subject: fix: resolve clippy warnings - Prefix unused variable auth_result with underscore - Prefix unused field git_data_path with underscore in Purgatory struct - Add #[allow(clippy::too_many_arguments)] to handle_receive_pack - Replace len() >= 1 with !is_empty() - Replace .last() with .next_back() on DoubleEndedIterator - Fix doc list item overindentation - Replace map_or(true, ...) with is_none_or(...) - Replace map_or(false, ...) with is_some_and(...) --- src/purgatory/sync/functions.rs | 8 ++++---- src/purgatory/sync/throttle.rs | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/purgatory/sync') diff --git a/src/purgatory/sync/functions.rs b/src/purgatory/sync/functions.rs index 1b9518d..bb7c0b9 100644 --- a/src/purgatory/sync/functions.rs +++ b/src/purgatory/sync/functions.rs @@ -35,7 +35,7 @@ fn extract_domain(url: &str) -> Option { let url = url.strip_prefix("https://").or_else(|| url.strip_prefix("http://"))?; // Remove user info if present (e.g., "user@host" -> "host") - let url = url.split('@').last()?; + let url = url.split('@').next_back()?; // Extract host (before first '/' or ':') let host = url.split('/').next()?; @@ -63,7 +63,7 @@ fn extract_domain(url: &str) -> Option { /// * `ctx` - The sync context providing repository data and OID information /// * `identifier` - The repository identifier (d-tag value) /// * `domain` - If Some, only return URLs from this specific domain. -/// If None, return any non-throttled URL. +/// If None, return any non-throttled URL. /// * `tried_urls` - URLs that have already been tried (will be skipped) /// * `throttle_manager` - Used to check if domains are throttled (when domain is None) /// @@ -126,7 +126,7 @@ pub async fn sync_identifier_next_url( // Merge and filter out our domain let all_urls: HashSet = announcement_urls .union(&pr_urls) - .filter(|url| our_domain.map_or(true, |d| !url.contains(d))) + .filter(|url| our_domain.is_none_or(|d| !url.contains(d))) .cloned() .collect(); @@ -231,7 +231,7 @@ pub async fn get_throttled_domains_with_untried_urls( // Merge and filter out our domain let all_urls: HashSet = announcement_urls .union(&pr_urls) - .filter(|url| our_domain.map_or(true, |d| !url.contains(d))) + .filter(|url| our_domain.is_none_or(|d| !url.contains(d))) .cloned() .collect(); diff --git a/src/purgatory/sync/throttle.rs b/src/purgatory/sync/throttle.rs index 05b0878..e6efe1f 100644 --- a/src/purgatory/sync/throttle.rs +++ b/src/purgatory/sync/throttle.rs @@ -152,7 +152,7 @@ impl DomainThrottle { while self .request_times .front() - .map_or(false, |t| now.duration_since(*t) >= window) + .is_some_and(|t| now.duration_since(*t) >= window) { self.request_times.pop_front(); } @@ -299,7 +299,7 @@ impl ThrottleManager { /// Returns true if the domain has no capacity for another request, /// either due to concurrent limit or rate limit. pub fn is_throttled(&self, domain: &str) -> bool { - self.throttles.get(domain).map_or(false, |entry| { + self.throttles.get(domain).is_some_and(|entry| { let throttle = entry.lock().unwrap(); !throttle.has_capacity() }) -- cgit v1.2.3