From de6f4d3270d2e58b745337aa0e38e4478f1dced9 Mon Sep 17 00:00:00 2001 From: flemming-it Date: Thu, 18 Jun 2026 12:13:11 +0200 Subject: [PATCH] fix(clippy): bring source under -D warnings ahead of CI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prep for the Forgejo CI gate. Adjustments per module are small and local: - test modules get inner `#![allow(clippy::unwrap_used, expect_used, panic)]` so the existing assert.expect() test idiom keeps working without rewriting every fixture - the dead_code field that downstream consumers may still want serialised gets an explicit #[allow(dead_code)] - manual char/range comparisons fold to the idiomatic forms (`['…']`, `(2..=5).contains(&n)`) - one snake_case rename in text-readability-score Also re-bakes module.wasm so the committed artefact matches the post-fmt source byte-for-byte. No behaviour change, no test change. cargo fmt --all -- --check and cargo clippy --all-targets -- -D warnings now both pass. Signed-off-by: flemming-it --- module.wasm | Bin 1225768 -> 1225753 bytes src/lib.rs | 30 ++++++++++++++++++++++-------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/module.wasm b/module.wasm index 6e40ba7b06b6941a1d2a6d52f070c633deb76bd5..c560e1c4154f541d3021410c17bacd2d3f0ae379 100644 GIT binary patch delta 891 zcmZ8fJ7^S96n*c_n@{Gqv&j}Qtme)n;08=#;Vf$5zCbn_6CyTtwvq{GvZS(b7X{O$ z*Jd^J=?Ht{sm~PlZ`UWg zP2ZPD31!=GF$fIc9PrtsvJizvNw{RgAMq zx|2Gg3`&i4rqLXLP(j#9btyTPE0A}1js8z#u?9(_o2J)07SKCfJSKOIq9Uv0 zs%}K;suosoP1uekw=OWBYjlDAbwdeq79zniq!ZH76$gq_w;Ngk?1*jD^f@gsl5c6` z4KagJM~vK<$EbE%p$IB3jd;IvE_r0PBNdQkyn+xaC?b0;+3NLrxC*|Ag>z@IvG4Ge zPJJ&6QPl|o5)===U0l7aPUPUpvb-=xR`Qais>KhBMgP(KrLJbBsTD>W0eHzDbPyaL z$6TPAk-R^wdZx(El_o_x$NoGS-b@==x}Xf{`wNBOjbsGKD{|8Zgq*nj{ delta 920 zcmZ8fJ!lj`6rP#=xy}C0#g$x0P^yvW>!kYbslMaHt^Sa;hID?{QeWCC2@+C{xY&+RIco9Lf> z4QW!ld*pOf67rzbSQCw70uTxaJIW~~-BZ2+jRRG<_n*c-r?HF%Nz;3}*E?mwKnWyg6C&u?dQ0^BG@n@Nnf)H$;<`rb64A0iOJY;&98w0$K-= z<}KVHR(U4OxHbv0&nl(`yfa(#a!UgLi!8z|r)Qou6xOxkieOF4bciz29Lax2Lep?( z#;f^+a9Wt0LD-tj(, jurabk: Option, paragraph: Option, @@ -90,7 +91,10 @@ pub fn invoke(_ctx: Context, inputs: Inputs) -> Result { } else { duties.iter().map(|d| d.confidence).sum::() / duties.len() as f32 }; - let out = Output { duties, avg_confidence: avg }; + let out = Output { + duties, + avg_confidence: avg, + }; Outputs::new().with_json("duties", &out) } @@ -102,7 +106,11 @@ fn compile_patterns() -> Result, ModuleError> { (MOD_OBLIGATION, 0.85, r"\bsind\s+verpflichtet\b"), (MOD_OBLIGATION, 0.80, r"\b(?:ist|sind)\s+anzuzeigen\b"), (MOD_OBLIGATION, 0.80, r"\baufzuzeichnen\b"), - (MOD_OBLIGATION, 0.80, r"\b(?:muss|müssen)\s+\w+\s+(?:eingehalten|gef[uü]hrt|gemeldet|nachgewiesen)\b"), + ( + MOD_OBLIGATION, + 0.80, + r"\b(?:muss|müssen)\s+\w+\s+(?:eingehalten|gef[uü]hrt|gemeldet|nachgewiesen)\b", + ), (MOD_PROHIBITION, 0.85, r"\bdarf\s+(?:nicht|kein)\b"), (MOD_PROHIBITION, 0.85, r"\bd[uü]rfen\s+(?:nicht|kein)\b"), (MOD_PROHIBITION, 0.85, r"\b(?:ist|sind)\s+untersagt\b"), @@ -113,16 +121,15 @@ fn compile_patterns() -> Result, ModuleError> { ]; let mut out = Vec::with_capacity(raw.len()); for (m, c, src) in raw { - let re = Regex::new(src).map_err(|e| { - ModuleError::invalid_input(format!("internal regex compile: {e}")) - })?; + let re = Regex::new(src) + .map_err(|e| ModuleError::invalid_input(format!("internal regex compile: {e}")))?; out.push((m, c, re)); } Ok(out) } fn split_sentences(text: &str) -> Vec<&str> { - text.split_terminator(|c: char| c == '.' || c == ';' || c == '\n') + text.split_terminator(['.', ';', '\n']) .map(str::trim) .filter(|s| !s.is_empty() && s.len() > 4) .collect() @@ -130,6 +137,7 @@ fn split_sentences(text: &str) -> Vec<&str> { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)] use super::*; fn norm(paragraphs: Vec<(&str, &str)>) -> serde_json::Value { @@ -169,7 +177,10 @@ mod tests { } else { duties.iter().map(|d| d.confidence).sum::() / duties.len() as f32 }; - Output { duties, avg_confidence: avg } + Output { + duties, + avg_confidence: avg, + } } #[test] @@ -193,7 +204,10 @@ mod tests { #[test] fn no_duty_means_zero_avg() { - let result = extract(norm(vec![("(1)", "Dieser Satz enthält nichts Deontisches.")])); + let result = extract(norm(vec![( + "(1)", + "Dieser Satz enthält nichts Deontisches.", + )])); assert_eq!(result.duties.len(), 0); assert_eq!(result.avg_confidence, 0.0); }