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/git/handlers.rs | 3 ++- src/git/sync.rs | 2 +- src/purgatory/mod.rs | 6 +++--- src/purgatory/sync/functions.rs | 8 ++++---- src/purgatory/sync/throttle.rs | 4 ++-- 5 files changed, 12 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/git/handlers.rs b/src/git/handlers.rs index 6d2e2d7..ff55e34 100644 --- a/src/git/handlers.rs +++ b/src/git/handlers.rs @@ -181,6 +181,7 @@ pub async fn handle_upload_pack( /// * `identifier` - The repository identifier (d tag) for authorization lookup /// * `owner_pubkey` - The owner's public key (hex) from the URL path, scoping authorization /// * `git_data_path` - Base path for git repositories (for syncing to other owner repos) +#[allow(clippy::too_many_arguments)] pub async fn handle_receive_pack( repo_path: PathBuf, request_body: Bytes, @@ -204,7 +205,7 @@ pub async fn handle_receive_pack( ); // check push is authorised - let auth_result = match authorize_push( + let _auth_result = match authorize_push( &database, identifier, owner_pubkey, diff --git a/src/git/sync.rs b/src/git/sync.rs index 949d8e1..2f43e6e 100644 --- a/src/git/sync.rs +++ b/src/git/sync.rs @@ -1310,7 +1310,7 @@ async fn process_purgatory_pr_events( fn extract_owner_from_repo_path(repo_path: &Path, git_data_path: &Path) -> Option { let relative = repo_path.strip_prefix(git_data_path).ok()?; let components: Vec<_> = relative.components().collect(); - if components.len() >= 1 { + if !components.is_empty() { components[0].as_os_str().to_str().map(|s| s.to_string()) } else { None diff --git a/src/purgatory/mod.rs b/src/purgatory/mod.rs index 894c941..9427c71 100644 --- a/src/purgatory/mod.rs +++ b/src/purgatory/mod.rs @@ -61,7 +61,7 @@ pub struct Purgatory { /// Maps repository identifier to sync queue entry with timing/backoff state. sync_queue: Arc>, - git_data_path: PathBuf, + _git_data_path: PathBuf, } impl Purgatory { @@ -71,7 +71,7 @@ impl Purgatory { state_events: Arc::new(DashMap::new()), pr_events: Arc::new(DashMap::new()), sync_queue: Arc::new(DashMap::new()), - git_data_path: git_data_path.into(), + _git_data_path: git_data_path.into(), } } @@ -135,7 +135,7 @@ impl Purgatory { if self .state_events .get(identifier) - .map_or(false, |entries| !entries.is_empty()) + .is_some_and(|entries| !entries.is_empty()) { return true; } 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