From d25dcaa0de7ef9012a75935d4da8fd68aaa1ddd4 Mon Sep 17 00:00:00 2001 From: glitchySid Date: Mon, 29 Dec 2025 00:49:53 +0530 Subject: [PATCH] fix: Resolve clippy warnings - allow dead code and collapse if statements --- src/config.rs | 10 ++++------ src/gemini.rs | 7 ++++--- src/gemini_errors.rs | 3 +++ src/prompt.rs | 5 ++--- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/config.rs b/src/config.rs index 937bc39..dca5b4a 100644 --- a/src/config.rs +++ b/src/config.rs @@ -73,10 +73,9 @@ impl Config { } pub fn get_or_prompt_api_key() -> Result> { - if let Ok(config) = Config::load() { - if !config.api_key.is_empty() { + if let Ok(config) = Config::load() + && !config.api_key.is_empty() { return Ok(config.api_key); - } } println!(); @@ -94,10 +93,9 @@ pub fn get_or_prompt_api_key() -> Result> { } pub fn get_or_prompt_download_folder() -> Result> { - if let Ok(config) = Config::load() { - if !config.download_folder.as_os_str().is_empty() && config.download_folder.exists() { + if let Ok(config) = Config::load() + && !config.download_folder.as_os_str().is_empty() && config.download_folder.exists() { return Ok(config.download_folder); - } } println!(); diff --git a/src/gemini.rs b/src/gemini.rs index af49da0..40811bf 100644 --- a/src/gemini.rs +++ b/src/gemini.rs @@ -16,7 +16,9 @@ pub struct GeminiClient { api_key: String, client: Client, base_url: String, + #[allow(dead_code)] model: String, + #[allow(dead_code)] timeout: Duration, } @@ -68,10 +70,9 @@ impl GeminiClient { ) -> Result { let url = self.build_url(); - if let (Some(cache), Some(base_path)) = (cache.as_ref(), base_path) { - if let Some(cached_response) = cache.get_cached_response(&filenames, base_path) { + if let (Some(cache), Some(base_path)) = (cache.as_ref(), base_path) + && let Some(cached_response) = cache.get_cached_response(&filenames, base_path) { return Ok(cached_response); - } } let prompt = PromptBuilder::new(filenames.clone()).build_categorization_prompt(); diff --git a/src/gemini_errors.rs b/src/gemini_errors.rs index 6dbddf9..a4a1cee 100644 --- a/src/gemini_errors.rs +++ b/src/gemini_errors.rs @@ -52,6 +52,7 @@ struct GeminiErrorResponse { #[derive(Debug, Deserialize)] struct GeminiErrorDetail { + #[allow(dead_code)] code: i32, message: String, status: String, @@ -62,10 +63,12 @@ struct GeminiErrorDetail { #[derive(Debug, Deserialize)] struct GeminiErrorDetailInfo { #[serde(rename = "@type")] + #[allow(dead_code)] error_type: String, #[serde(rename = "retryDelay")] retry_delay: Option, quota_limit: Option, + #[allow(dead_code)] quota_metro: Option, } diff --git a/src/prompt.rs b/src/prompt.rs index c27e8c9..26f61bd 100644 --- a/src/prompt.rs +++ b/src/prompt.rs @@ -119,11 +119,10 @@ impl Prompter { } pub fn expand_home(path: &str) -> String { - if path.starts_with("~/") { - if let Some(base_dirs) = BaseDirs::new() { + if path.starts_with("~/") + && let Some(base_dirs) = BaseDirs::new() { let home = base_dirs.home_dir(); return path.replacen("~", &home.to_string_lossy(), 1); - } } path.to_string() }