fix: Resolve clippy warnings - allow dead code and collapse if statements
This commit is contained in:
@@ -73,11 +73,10 @@ 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!();
|
||||||
println!("{}", "🔑 NoEntropy Configuration".bold().cyan());
|
println!("{}", "🔑 NoEntropy Configuration".bold().cyan());
|
||||||
@@ -94,11 +93,10 @@ 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!();
|
||||||
println!("{}", "📁 Download folder not configured.".yellow());
|
println!("{}", "📁 Download folder not configured.".yellow());
|
||||||
|
|||||||
@@ -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,11 +70,10 @@ 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();
|
||||||
let request_body = self.build_categorization_request(&prompt);
|
let request_body = self.build_categorization_request(&prompt);
|
||||||
|
|||||||
@@ -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>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -119,12 +119,11 @@ 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()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user