From 1a35f0f89c0f8852cbd09945a490392939170d02 Mon Sep 17 00:00:00 2001 From: wlkns-dev Date: Sun, 22 Nov 2026 10:41:37 +0100 Subject: [PATCH] style: Clippy-Hinweise in health.rs (#1197) Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01GmHhg7qE8FdhchzsBrwgjZ --- crates/nexus-api/src/health.rs | 48 ++++++++++++++++------------------ 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/crates/nexus-api/src/health.rs b/crates/nexus-api/src/health.rs index fae7029..b78fa46 100644 --- a/crates/nexus-api/src/health.rs +++ b/crates/nexus-api/src/health.rs @@ -186,23 +186,23 @@ pub fn bewerte(e: &Eingabe) -> Gesundheit { } if let Some(h) = &e.host { - if let Some(ram) = h.ram { - if let Some(s) = anteil(ram.belegt_mb, ram.gesamt_mb).and_then(stufe) { - gruende.push(grund( - s, - "Arbeitsspeicher", - format!("Über {} Prozent belegt", schwelle(s)), - )); - } + if let Some(s) = h + .ram + .and_then(|ram| anteil(ram.belegt_mb, ram.gesamt_mb)) + .and_then(stufe) + { + gruende.push(grund( + s, + "Arbeitsspeicher", + format!("Über {} Prozent belegt", schwelle(s)), + )); } - if let Some(cpu) = h.cpu_prozent { - if cpu >= KNAPP_PROZENT { - gruende.push(grund( - Schwere::Eingeschraenkt, - "CPU", - format!("Auslastung über {} Prozent", KNAPP_PROZENT as u32), - )); - } + if h.cpu_prozent.is_some_and(|cpu| cpu >= KNAPP_PROZENT) { + gruende.push(grund( + Schwere::Eingeschraenkt, + "CPU", + format!("Auslastung über {} Prozent", KNAPP_PROZENT as u32), + )); } if let Some(f) = &h.fehler { gruende.push(grund( @@ -223,14 +223,12 @@ pub fn bewerte(e: &Eingabe) -> Gesundheit { ), )); } - if let Some(w) = e.aelteste_wartezeit_s { - if w >= WARTEZEIT_WARNUNG_S { - gruende.push(grund( - Schwere::Eingeschraenkt, - "Warteschlange", - format!("Älteste Anfrage wartet seit {w} Sekunden"), - )); - } + if let Some(w) = e.aelteste_wartezeit_s.filter(|w| *w >= WARTEZEIT_WARNUNG_S) { + gruende.push(grund( + Schwere::Eingeschraenkt, + "Warteschlange", + format!("Älteste Anfrage wartet seit {w} Sekunden"), + )); } // Veraltete Messwerte werden nie als „in Ordnung“ gewertet. @@ -247,7 +245,7 @@ pub fn bewerte(e: &Eingabe) -> Gesundheit { } } - gruende.sort_by(|a, b| b.schwere.cmp(&a.schwere)); + gruende.sort_by_key(|g| std::cmp::Reverse(g.schwere)); let schwerste = gruende.first().map(|g| g.schwere); let noch_nichts_gemessen = e.gpu_alter_s.is_none() && e.host_alter_s.is_none(); let zustand = match schwerste {