From d7208f98cf4df51332acf71e5dc00b4e13fd268f Mon Sep 17 00:00:00 2001 From: Bartal Laearsson Date: Tue, 25 Aug 2026 13:14:19 +0100 Subject: [PATCH] clippy fixes --- src/fetcher.rs | 4 +--- src/main.rs | 13 +++++++++---- src/scraper.rs | 6 +----- src/url_utils.rs | 5 +---- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/fetcher.rs b/src/fetcher.rs index 5dabce8..9597fc2 100644 --- a/src/fetcher.rs +++ b/src/fetcher.rs @@ -32,9 +32,7 @@ impl Fetcher { Ok(b) => b, Err(e) => { if attempt < MAX_RETRIES { - log::warn!( - "retry {attempt}/{MAX_RETRIES}: body read failed ({e})" - ); + log::warn!("retry {attempt}/{MAX_RETRIES}: body read failed ({e})"); tokio::time::sleep(Duration::from_secs( RETRY_BACKOFF_SECS * u64::from(attempt), )) diff --git a/src/main.rs b/src/main.rs index 1054305..4de36d3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -109,9 +109,10 @@ async fn main() -> Result<()> { }; let logs_dir = { - let output_name = output_dir - .file_name() - .map_or_else(|| "output".to_string(), |n| n.to_string_lossy().into_owned()); + let output_name = output_dir.file_name().map_or_else( + || "output".to_string(), + |n| n.to_string_lossy().into_owned(), + ); let logs_name = format!("{output_name}_logs"); output_dir .parent() @@ -147,7 +148,11 @@ async fn main() -> Result<()> { log::info!("Base host: {base_host}"); log::info!( "Subdomain crawling: {}", - if args.subdomains { "enabled" } else { "disabled" } + if args.subdomains { + "enabled" + } else { + "disabled" + } ); log::info!("Output dir: {}", output_dir.display()); log::info!("Logs dir: {}", logs_dir.display()); diff --git a/src/scraper.rs b/src/scraper.rs index f5b97e5..225f91f 100644 --- a/src/scraper.rs +++ b/src/scraper.rs @@ -112,11 +112,7 @@ impl Scraper { } } - fn extract_new_links( - &self, - html: &str, - final_url: &Url, - ) -> (usize, Vec) { + fn extract_new_links(&self, html: &str, final_url: &Url) -> (usize, Vec) { let links = extract_links(html, final_url, &self.base_host, self.allow_subdomains); let new_count = links.len(); let new_links: Vec = links diff --git a/src/url_utils.rs b/src/url_utils.rs index de93fce..8b75934 100644 --- a/src/url_utils.rs +++ b/src/url_utils.rs @@ -111,10 +111,7 @@ pub fn url_to_filename(url: &Url, content_type: &str) -> String { return format!("{}{}", &hash[..16], ext); } - let host = url - .host_str() - .unwrap_or("unknown") - .replace(['.', ':'], "_"); + let host = url.host_str().unwrap_or("unknown").replace(['.', ':'], "_"); let path = url.path().trim_start_matches('/'); let path = if path.is_empty() { "index" } else { path }; let path = path.trim_end_matches('/');