Expand description
Assembling one measurement: the inventory and the registry in, a QualityReport out.
§One discovery, many renderings
The crate is parsed once, the registry is read once, and everything downstream — the
terminal rendering, the JSON, the HTTP response, the Cockpit panel, the CI annotations
— is a reading of the single value this module returns. That is the same relationship
every other projection in this executable has with the registry, and it is why a
--json report and a human report can never disagree about whether the gate passed.
§What it measures
src/**.rs --syn--> Inventory --policy--> item and module findings
registry + clap tree + OpenAPI --parity--> operation findingsuse majordomus_cli::quality::report;
// a crate of one module, documented, exampled and tested: the shape of a clean report
let dir = tempfile::tempdir().unwrap();
let src = dir.path().join("src");
std::fs::create_dir_all(&src).unwrap();
std::fs::write(src.join("lib.rs"), concat!(
"//! A crate that does one thing, and this header says at some length what that one\n",
"//! thing is, which is what the module policy asks of every exported module here.\n",
"//!\n",
"//! ```\n",
"//! assert_eq!(majordomus_cli::two(), 2);\n",
"//! ```\n",
"/// Answers with two, every time, which is more than the signature promises.\n",
"///\n",
"/// ```\n",
"/// assert_eq!(majordomus_cli::two(), 2);\n",
"/// ```\n",
"pub fn two() -> usize { 2 }\n",
"#[cfg(test)]\n",
"mod tests { #[test] fn it_is_two() { assert_eq!(super::two(), 2); } }\n",
)).unwrap();
let report = report::rust_only(dir.path(), "a-crate").unwrap();
assert!(report.passes(), "{:?}", report.violations);
assert_eq!(report.modules.modules, 1);
assert_eq!(report.public_api.owe_example, 1);