Fix clippy warnings for CI

This commit is contained in:
Rasyidan Akbar F. 2026-03-17 22:02:58 +07:00
commit 83d362afcd
5 changed files with 15 additions and 25 deletions

View file

@ -98,7 +98,7 @@ impl Cache {
let mut newest: Option<DateTime<Utc>> = None;
if self.root.exists() {
self.walk(&self.root, &mut |p| {
Self::walk(&self.root, &mut |p| {
if let Ok(meta) = fs::metadata(p)
&& meta.is_file()
{
@ -130,7 +130,7 @@ impl Cache {
}
let mut removed = 0usize;
let mut failed = Vec::new();
self.walk(&self.root, &mut |p| {
Self::walk(&self.root, &mut |p| {
if p.is_file() {
match fs::remove_file(p) {
Ok(_) => removed += 1,
@ -141,12 +141,12 @@ impl Cache {
Ok((removed, failed))
}
fn walk<F: FnMut(&Path)>(&self, dir: &Path, f: &mut F) -> Result<(), IdxError> {
fn walk<F: FnMut(&Path)>(dir: &Path, f: &mut F) -> Result<(), IdxError> {
for entry in fs::read_dir(dir).map_err(|e| IdxError::Io(e.to_string()))? {
let entry = entry.map_err(|e| IdxError::Io(e.to_string()))?;
let path = entry.path();
if path.is_dir() {
self.walk(&path, f)?;
Self::walk(&path, f)?;
} else {
f(&path);
}
@ -176,8 +176,7 @@ impl Cache {
Ok(e) => e,
Err(e) => {
eprintln!(
"warning: corrupted cache entry for {}/{}, treating as miss: {}",
data_type, symbol, e
"warning: corrupted cache entry for {data_type}/{symbol}, treating as miss: {e}"
);
let _ = fs::remove_file(&path);
return Ok(None);

View file

@ -423,10 +423,7 @@ fn handle_flow(args: &FlowArgs, config: &IdxConfig) -> Result<(), IdxError> {
let flow = db::query_bing_flow(&conn, ticker_id)?;
let Some(flow) = flow else {
println!(
"No institutional flow data. Run: idx ownership import --fetch-bing {}",
symbol
);
println!("No institutional flow data. Run: idx ownership import --fetch-bing {symbol}");
return Ok(());
};
@ -590,7 +587,7 @@ fn handle_resolve(args: &ResolveArgs, config: &IdxConfig) -> Result<(), IdxError
}
ResolveCommand::Map { alias, entity } => {
db::manual_map(&conn, alias, entity)?;
println!("Mapped alias '{}' -> '{}'.", alias, entity);
println!("Mapped alias '{alias}' -> '{entity}'.");
Ok(())
}
ResolveCommand::Merge { keep, merge } => {
@ -619,8 +616,7 @@ fn handle_resolve(args: &ResolveArgs, config: &IdxConfig) -> Result<(), IdxError
db::merge_entities(&conn, *keep, *merge)?;
println!(
"Merged entity {} into {} (aliases: {}, ksei_holdings: {}, bing_holdings: {}).",
merge, keep, alias_updates, ksei_updates, bing_updates
"Merged entity {merge} into {keep} (aliases: {alias_updates}, ksei_holdings: {ksei_updates}, bing_holdings: {bing_updates})."
);
Ok(())
}

View file

@ -136,8 +136,7 @@ impl IdxConfig {
OutputFormat::Table
} else {
return Err(IdxError::ConfigError(format!(
"invalid IDX_OUTPUT value: '{}', expected 'json' or 'table'",
output
"invalid IDX_OUTPUT value: '{output}', expected 'json' or 'table'"
)));
};
}
@ -277,8 +276,7 @@ fn normalize_config_value(key: &str, value: &str) -> Result<toml::Value, IdxErro
"general.output" => {
if !value.eq_ignore_ascii_case("table") && !value.eq_ignore_ascii_case("json") {
return Err(IdxError::InvalidInput(format!(
"invalid output format '{}': expected 'table' or 'json'",
value
"invalid output format '{value}': expected 'table' or 'json'"
)));
}
Ok(toml::Value::String(value.to_ascii_lowercase()))
@ -286,14 +284,12 @@ fn normalize_config_value(key: &str, value: &str) -> Result<toml::Value, IdxErro
"cache.quote_ttl" | "cache.fundamental_ttl" => {
let parsed: i64 = value.parse().map_err(|_| {
IdxError::InvalidInput(format!(
"invalid TTL value '{}': must be a non-negative integer",
value
"invalid TTL value '{value}': must be a non-negative integer"
))
})?;
if parsed < 0 {
return Err(IdxError::InvalidInput(format!(
"invalid TTL value '{}': must be non-negative",
value
"invalid TTL value '{value}': must be non-negative"
)));
}
Ok(toml::Value::Integer(parsed))
@ -309,8 +305,7 @@ fn normalize_config_value(key: &str, value: &str) -> Result<toml::Value, IdxErro
"general.color" => {
if !value.eq_ignore_ascii_case("true") && !value.eq_ignore_ascii_case("false") {
return Err(IdxError::InvalidInput(format!(
"invalid color value '{}': expected 'true' or 'false'",
value
"invalid color value '{value}': expected 'true' or 'false'"
)));
}
Ok(toml::Value::Boolean(value.eq_ignore_ascii_case("true")))

View file

@ -396,7 +396,7 @@ fn format_idr_option(value: Option<f64>) -> String {
fn format_float(value: Option<f64>, precision: usize) -> String {
value
.map(|v| format!("{v:.prec$}", prec = precision))
.map(|v| format!("{v:.precision$}"))
.unwrap_or_else(|| "-".to_string())
}

View file

@ -182,7 +182,7 @@ fn detect_root_node(conn: &Connection, root: &str) -> Result<String, IdxError> {
return Ok(format!("ticker:{code}"));
}
let q = format!("%{}%", root);
let q = format!("%{root}%");
let maybe_entity_id = conn
.query_row(
"SELECT id