fix: Resolve clippy warnings - allow dead code and collapse if statements
This commit is contained in:
@@ -73,10 +73,9 @@ impl Config {
|
||||
}
|
||||
|
||||
pub fn get_or_prompt_api_key() -> Result<String, Box<dyn std::error::Error>> {
|
||||
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<String, 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 !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!();
|
||||
|
||||
@@ -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<OrganizationPlan, GeminiError> {
|
||||
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();
|
||||
|
||||
@@ -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<String>,
|
||||
quota_limit: Option<String>,
|
||||
#[allow(dead_code)]
|
||||
quota_metro: Option<String>,
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user