fix: satisfy clippy 1.97 lints failing on CI

- sanitize_current_ratio: and_then if/else -> filter
- screener/graph sorts: sort_by with reversed cmp -> sort_by_key(Reverse)
- insert_ksei_holdings_rows: manual Result match -> ?

Fixes the Clippy step on ubuntu-latest (rust 1.97) that the nix
toolchain (1.93.1) did not flag.
This commit is contained in:
hermes 2026-07-31 12:14:58 +00:00
commit 09f7fe420c
4 changed files with 5 additions and 14 deletions

View file

@ -184,13 +184,7 @@ fn normalize_percentish(value: Option<f64>) -> Option<f64> {
} }
fn sanitize_current_ratio(value: Option<f64>) -> Option<f64> { fn sanitize_current_ratio(value: Option<f64>) -> Option<f64> {
value.and_then(|number| { value.filter(|number| number.is_finite() && *number >= 0.01)
if !number.is_finite() || number < 0.01 {
None
} else {
Some(number)
}
})
} }
fn round_price(value: f64) -> i64 { fn round_price(value: f64) -> i64 {

View file

@ -983,10 +983,10 @@ fn sort_screener_quotes(quotes: &mut [Quote], filter: &str) {
}); });
} }
"high-volume" => { "high-volume" => {
quotes.sort_by(|a, b| b.volume.cmp(&a.volume)); quotes.sort_by_key(|quote| std::cmp::Reverse(quote.volume));
} }
"large-cap" => { "large-cap" => {
quotes.sort_by(|a, b| b.market_cap.unwrap_or(0).cmp(&a.market_cap.unwrap_or(0))); quotes.sort_by_key(|quote| std::cmp::Reverse(quote.market_cap.unwrap_or(0)));
} }
_ => {} _ => {}
} }

View file

@ -196,10 +196,7 @@ fn insert_ksei_holdings_rows(
) )
.map_err(|e| IdxError::DatabaseError(e.to_string())); .map_err(|e| IdxError::DatabaseError(e.to_string()));
match changed { inserted += changed?;
Ok(n) => inserted += n,
Err(err) => return Err(err),
}
} }
Ok(inserted) Ok(inserted)

View file

@ -122,7 +122,7 @@ pub fn format_graph_text(nodes: &[GraphNode], edges: &[GraphEdge]) -> String {
out.push_str(&format!("nodes: {} edges: {}\n", nodes.len(), edges.len())); out.push_str(&format!("nodes: {} edges: {}\n", nodes.len(), edges.len()));
for (ticker_id, mut rels) in ticker_to_entities { for (ticker_id, mut rels) in ticker_to_entities {
rels.sort_by(|a, b| b.percentage_bps.cmp(&a.percentage_bps)); rels.sort_by_key(|edge| std::cmp::Reverse(edge.percentage_bps));
let ticker_label = labels.get(ticker_id).map(|v| v.0).unwrap_or(ticker_id); let ticker_label = labels.get(ticker_id).map(|v| v.0).unwrap_or(ticker_id);
out.push_str(&format!("\n{ticker_label} [TICKER]\n")); out.push_str(&format!("\n{ticker_label} [TICKER]\n"));