Skip to content

Commit e6a3c04

Browse files
committed
refactor: address clippy warnings and remove dead code
- Replace map_or with is_none_or for cleaner Option handling - Remove unused detect_six_hour_reset method - Simplify format! to to_string where appropriate - Convert single-match to if statement - Remove unused system_events module
1 parent a0cf2bd commit e6a3c04

File tree

2 files changed

+4
-25
lines changed

2 files changed

+4
-25
lines changed

src-tauri/src/adaptive_poller.rs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ impl TimeWindowedTracker {
181181
samples.windows(2).fold(0u8, |total, w| {
182182
if w[1] > w[0] {
183183
let change = w[1] - w[0];
184-
if max_change.map_or(true, |max| change <= max) {
184+
if max_change.is_none_or(|max| change <= max) {
185185
total.saturating_add(change)
186186
} else {
187187
total
@@ -200,23 +200,6 @@ impl TimeWindowedTracker {
200200
self.calculate_momentum(window, now, |m| m.weekly_pct(), None)
201201
}
202202

203-
fn detect_six_hour_reset(&self) -> bool {
204-
if self.history.len() < 2 {
205-
return false;
206-
}
207-
208-
let last_two: Vec<_> = self.history.values().rev().take(2).collect();
209-
if last_two.len() < 2 {
210-
return false;
211-
}
212-
213-
let latest = last_two[0].six_hour_pct();
214-
let previous = last_two[1].six_hour_pct();
215-
216-
// Reset detected: significant drop (>20%)
217-
previous > latest && (previous - latest) > 20
218-
}
219-
220203
fn time_since_any_change(&self, now: Instant) -> Duration {
221204
if self.history.len() < 2 {
222205
return Duration::MAX;

src-tauri/src/lib.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
mod adaptive_poller;
2-
mod system_events;
32

43
use adaptive_poller::{AdaptivePoller, PollerConfig, UsageMetrics};
54
use serde::{Deserialize, Serialize};
@@ -382,7 +381,7 @@ fn update_tray_icon(
382381
// Parse ISO 8601 timestamp and format it nicely
383382
s.split('T')
384383
.next()
385-
.map(|date| format!("{}", date))
384+
.map(|date| date.to_string())
386385
.unwrap_or_else(|| s.clone())
387386
})
388387
.unwrap_or_else(|| "Unknown".to_string())
@@ -537,11 +536,8 @@ pub fn run() {
537536
TrayIconBuilder::with_id("main")
538537
.icon(icon)
539538
.menu(&menu)
540-
.on_menu_event(|app, event| match event.id.as_ref() {
541-
"quit" => {
542-
app.exit(0);
543-
}
544-
_ => {}
539+
.on_menu_event(|app, event| if event.id.as_ref() == "quit" {
540+
app.exit(0);
545541
})
546542
.build(app)?;
547543

0 commit comments

Comments
 (0)