fix(clippy): bring source under -D warnings ahead of CI
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 <sf@flemming.it>
This commit is contained in:
parent
6fc151f2cc
commit
28d7dfa48f
2 changed files with 24 additions and 10 deletions
BIN
module.wasm
BIN
module.wasm
Binary file not shown.
34
src/lib.rs
34
src/lib.rs
|
|
@ -49,12 +49,11 @@ pub fn invoke(_ctx: Context, inputs: Inputs) -> Result<Outputs, ModuleError> {
|
|||
.require_json("norm")
|
||||
.map_err(|e| ModuleError::invalid_input(format!("norm shape: {e}")))?;
|
||||
|
||||
let re_para = Regex::new(r"§\s*(\d+[a-z]?)\s+([A-Z][A-Za-z0-9]+)")
|
||||
.map_err(internal_re)?;
|
||||
let re_art = Regex::new(r"Art(?:ikel|\.)\s*(\d+[a-z]?)\s+([A-Z][A-Za-z0-9]+)")
|
||||
.map_err(internal_re)?;
|
||||
let re_ivm = Regex::new(r"i\.\s?V\.\s?m\.\s+(?:§|Art\.?)\s*(\d+[a-z]?)")
|
||||
.map_err(internal_re)?;
|
||||
let re_para = Regex::new(r"§\s*(\d+[a-z]?)\s+([A-Z][A-Za-z0-9]+)").map_err(internal_re)?;
|
||||
let re_art =
|
||||
Regex::new(r"Art(?:ikel|\.)\s*(\d+[a-z]?)\s+([A-Z][A-Za-z0-9]+)").map_err(internal_re)?;
|
||||
let re_ivm =
|
||||
Regex::new(r"i\.\s?V\.\s?m\.\s+(?:§|Art\.?)\s*(\d+[a-z]?)").map_err(internal_re)?;
|
||||
|
||||
let from_eli = norm.eli.unwrap_or_else(|| "eli/?".into());
|
||||
let mut citations = Vec::new();
|
||||
|
|
@ -93,7 +92,10 @@ pub fn invoke(_ctx: Context, inputs: Inputs) -> Result<Outputs, ModuleError> {
|
|||
}
|
||||
}
|
||||
|
||||
let out = Output { from: from_eli, citations };
|
||||
let out = Output {
|
||||
from: from_eli,
|
||||
citations,
|
||||
};
|
||||
Outputs::new().with_json("citations", &out)
|
||||
}
|
||||
|
||||
|
|
@ -103,6 +105,7 @@ fn internal_re<E: core::fmt::Display>(e: E) -> ModuleError {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
|
||||
use super::*;
|
||||
use regex::Regex;
|
||||
|
||||
|
|
@ -114,20 +117,31 @@ mod tests {
|
|||
for p in &norm.paragraphs {
|
||||
for c in re_para.captures_iter(&p.text) {
|
||||
cs.push(Citation {
|
||||
to: format!("eli/bund/{}/{}", c[2].to_ascii_lowercase(), c[1].to_ascii_lowercase()),
|
||||
to: format!(
|
||||
"eli/bund/{}/{}",
|
||||
c[2].to_ascii_lowercase(),
|
||||
c[1].to_ascii_lowercase()
|
||||
),
|
||||
kind: "cites",
|
||||
raw: c[0].to_string(),
|
||||
});
|
||||
}
|
||||
for c in re_art.captures_iter(&p.text) {
|
||||
cs.push(Citation {
|
||||
to: format!("eli/eu/{}/art{}", c[2].to_ascii_lowercase(), c[1].to_ascii_lowercase()),
|
||||
to: format!(
|
||||
"eli/eu/{}/art{}",
|
||||
c[2].to_ascii_lowercase(),
|
||||
c[1].to_ascii_lowercase()
|
||||
),
|
||||
kind: "cites",
|
||||
raw: c[0].to_string(),
|
||||
});
|
||||
}
|
||||
}
|
||||
Output { from: norm.eli.unwrap_or_default(), citations: cs }
|
||||
Output {
|
||||
from: norm.eli.unwrap_or_default(),
|
||||
citations: cs,
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue