Skip to content

Commit bd8ffdf

Browse files
mivertowskiclaude
andcommitted
Fix clippy warnings in ringkernel-procint and ringkernel-accnet
- Use sort_by_key() with Reverse instead of sort_by() in 3 places - Use checked_div() instead of manual division check in charts.rs Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 39b323c commit bd8ffdf

File tree

4 files changed

+4
-8
lines changed

4 files changed

+4
-8
lines changed

crates/ringkernel-accnet/src/gui/charts.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -671,11 +671,7 @@ impl MethodDistribution {
671671

672672
for (i, label) in labels.iter().enumerate() {
673673
let x = rect.left() + 5.0 + legend_spacing * (i as f32 + 0.5);
674-
let pct = if total > 0 {
675-
self.counts[i] * 100 / total
676-
} else {
677-
0
678-
};
674+
let pct = (self.counts[i] * 100).checked_div(total).unwrap_or(0);
679675

680676
painter.circle_filled(Pos2::new(x - 15.0, legend_y + 5.0), 4.0, colors[i]);
681677
painter.text(

crates/ringkernel-accnet/src/gui/heatmaps.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ impl ActivityHeatmap {
151151
pub fn from_network_top_accounts(network: &AccountingNetwork, top_n: usize) -> Self {
152152
// Get top N accounts by transaction count
153153
let mut accounts: Vec<_> = network.accounts.iter().enumerate().collect();
154-
accounts.sort_by(|a, b| b.1.transaction_count.cmp(&a.1.transaction_count));
154+
accounts.sort_by_key(|a| std::cmp::Reverse(a.1.transaction_count));
155155
accounts.truncate(top_n);
156156

157157
let mut data = vec![vec![0.0f32; 8]; accounts.len()];

crates/ringkernel-procint/src/analytics/pattern_analysis.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl PatternAggregator {
7676
/// Get top patterns by frequency.
7777
pub fn top_patterns(&self, n: usize) -> Vec<&PatternSummary> {
7878
let mut sorted: Vec<_> = self.recent_patterns.iter().collect();
79-
sorted.sort_by(|a, b| b.frequency.cmp(&a.frequency));
79+
sorted.sort_by_key(|a| std::cmp::Reverse(a.frequency));
8080
sorted.truncate(n);
8181
sorted
8282
}

crates/ringkernel-procint/src/gui/app.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ impl ProcessIntelligenceApp {
384384

385385
// Get variations sorted by count
386386
let mut variations: Vec<_> = self.coordinator.variations().values().collect();
387-
variations.sort_by(|a, b| b.count.cmp(&a.count));
387+
variations.sort_by_key(|a| std::cmp::Reverse(a.count));
388388

389389
// Get activity names and colors
390390
let sector = self.coordinator.pipeline().sector();

0 commit comments

Comments
 (0)