use crate::parser::ParsedDocument;
use crate::rules::structural::AIL002;
use crate::rules::{Rule, RuleContext, RuleId, Severity, Violation};
#[derive(Debug, Default)]
pub struct EmptyFileRule;
impl Rule for EmptyFileRule {
fn id(&self) -> RuleId {
AIL002
}
fn default_severity(&self) -> Severity {
Severity::Warning
}
fn description(&self) -> &'static str {
"Guidance file is empty or whitespace-only."
}
fn fix_hint(&self) -> &'static str {
"Add content, or delete the file."
}
fn run(&self, doc: &ParsedDocument, _ctx: &RuleContext<'_>) -> Vec<Violation> {
if !doc.raw.trim().is_empty() {
return Vec::new();
}
vec![Violation::new(
AIL002,
self.default_severity(),
doc.path.clone(),
"file is empty or contains only whitespace",
)]
}
}