use crate::finding::{Finding, Severity};
use crate::scope::Scope;
use headwater_census::census::Census;
pub const RULE: &str = "language.outside_root.refused";
pub const SCOPE: Scope = Scope::taxonomy();
pub const VERSION: u32 = 1;
pub const EXPORTABLE_AS: crate::scope::ExportTargets = &[];
pub fn findings(census: &Census, source: &str) -> Vec<Finding> {
let at = |message: String, remediation: &str| Finding {
rule: RULE,
severity: Severity::Error,
obligation: None,
path: source.to_string(),
line: 0,
column: 0,
message,
remediation: remediation.to_string(),
patch: None,
};
let unmatched = census.outside.unmatched.iter().map(|entry| {
at(
format!(
"`regimes.language.{}.outside_root` lists `{}`, and it matches no file: {}",
entry.regime, entry.pattern, entry.reason
),
"correct the pattern, or take it off the list if the file is gone",
)
});
let refused = census.outside.refused.iter().map(|entry| {
at(
format!(
"`regimes.language.{}.outside_root` lists `{}`, and HW-DR-0084 refuses it: {}",
entry.regime, entry.pattern, entry.reason
),
"take the pattern off the list, or list the real file outside the corpus root",
)
});
unmatched.chain(refused).collect()
}