use crate::invariant::rules::util::list_files_with_ext;
use crate::invariant::{Category, Context, Invariant, Outcome};
use std::fs;
pub struct TodoCount;
impl Invariant for TodoCount {
fn id(&self) -> &'static str {
"health.todo-count"
}
fn category(&self) -> Category {
Category::Health
}
fn intent(&self) -> &'static str {
"Track TODO/FIXME density (informational; never fails on its own)."
}
fn adr(&self) -> Option<&'static str> {
Some("ADR-0013")
}
fn evaluate(&self, ctx: &Context) -> Outcome {
let mut count = 0usize;
for path in list_files_with_ext(ctx.root(), "rs") {
let Ok(content) = fs::read_to_string(&path) else {
continue;
};
for line in content.lines() {
if line.contains("TODO") || line.contains("FIXME") {
count += 1;
}
}
}
Outcome::pass_with(format!("{count} TODO/FIXME occurrence(s) in *.rs"))
}
}