fix: Resolve clippy warnings - allow dead code and collapse if statements

This commit is contained in:
glitchySid
2025-12-29 00:49:53 +05:30
parent 2dc269b148
commit d25dcaa0de
4 changed files with 13 additions and 12 deletions

View File

@@ -73,10 +73,9 @@ impl Config {
} }
pub fn get_or_prompt_api_key() -> Result<String, Box<dyn std::error::Error>> { pub fn get_or_prompt_api_key() -> Result<String, Box<dyn std::error::Error>> {
if let Ok(config) = Config::load() { if let Ok(config) = Config::load()
if !config.api_key.is_empty() { && !config.api_key.is_empty() {
return Ok(config.api_key); return Ok(config.api_key);
}
} }
println!(); println!();
@@ -94,10 +93,9 @@ pub fn get_or_prompt_api_key() -> Result<String, Box<dyn std::error::Error>> {
} }
pub fn get_or_prompt_download_folder() -> Result<PathBuf, Box<dyn std::error::Error>> { pub fn get_or_prompt_download_folder() -> Result<PathBuf, Box<dyn std::error::Error>> {
if let Ok(config) = Config::load() { if let Ok(config) = Config::load()
if !config.download_folder.as_os_str().is_empty() && config.download_folder.exists() { && !config.download_folder.as_os_str().is_empty() && config.download_folder.exists() {
return Ok(config.download_folder); return Ok(config.download_folder);
}
} }
println!(); println!();

View File

@@ -16,7 +16,9 @@ pub struct GeminiClient {
api_key: String, api_key: String,
client: Client, client: Client,
base_url: String, base_url: String,
#[allow(dead_code)]
model: String, model: String,
#[allow(dead_code)]
timeout: Duration, timeout: Duration,
} }
@@ -68,10 +70,9 @@ impl GeminiClient {
) -> Result<OrganizationPlan, GeminiError> { ) -> Result<OrganizationPlan, GeminiError> {
let url = self.build_url(); let url = self.build_url();
if let (Some(cache), Some(base_path)) = (cache.as_ref(), base_path) { if let (Some(cache), Some(base_path)) = (cache.as_ref(), base_path)
if let Some(cached_response) = cache.get_cached_response(&filenames, base_path) { && let Some(cached_response) = cache.get_cached_response(&filenames, base_path) {
return Ok(cached_response); return Ok(cached_response);
}
} }
let prompt = PromptBuilder::new(filenames.clone()).build_categorization_prompt(); let prompt = PromptBuilder::new(filenames.clone()).build_categorization_prompt();

View File

@@ -52,6 +52,7 @@ struct GeminiErrorResponse {
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]
struct GeminiErrorDetail { struct GeminiErrorDetail {
#[allow(dead_code)]
code: i32, code: i32,
message: String, message: String,
status: String, status: String,
@@ -62,10 +63,12 @@ struct GeminiErrorDetail {
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]
struct GeminiErrorDetailInfo { struct GeminiErrorDetailInfo {
#[serde(rename = "@type")] #[serde(rename = "@type")]
#[allow(dead_code)]
error_type: String, error_type: String,
#[serde(rename = "retryDelay")] #[serde(rename = "retryDelay")]
retry_delay: Option<String>, retry_delay: Option<String>,
quota_limit: Option<String>, quota_limit: Option<String>,
#[allow(dead_code)]
quota_metro: Option<String>, quota_metro: Option<String>,
} }

View File

@@ -119,11 +119,10 @@ impl Prompter {
} }
pub fn expand_home(path: &str) -> String { pub fn expand_home(path: &str) -> String {
if path.starts_with("~/") { if path.starts_with("~/")
if let Some(base_dirs) = BaseDirs::new() { && let Some(base_dirs) = BaseDirs::new() {
let home = base_dirs.home_dir(); let home = base_dirs.home_dir();
return path.replacen("~", &home.to_string_lossy(), 1); return path.replacen("~", &home.to_string_lossy(), 1);
}
} }
path.to_string() path.to_string()
} }