ailint_core/rules/structural/
empty_file.rs1use crate::parser::ParsedDocument;
6use crate::rules::structural::AIL002;
7use crate::rules::{Rule, RuleContext, RuleId, Severity, Violation};
8
9#[derive(Debug, Default)]
11pub struct EmptyFileRule;
12
13impl Rule for EmptyFileRule {
14 fn id(&self) -> RuleId {
15 AIL002
16 }
17
18 fn default_severity(&self) -> Severity {
19 Severity::Warning
20 }
21
22 fn description(&self) -> &'static str {
23 "Guidance file is empty or whitespace-only."
24 }
25
26 fn fix_hint(&self) -> &'static str {
27 "Add content, or delete the file."
28 }
29
30 fn run(&self, doc: &ParsedDocument, _ctx: &RuleContext<'_>) -> Vec<Violation> {
31 if !doc.raw.trim().is_empty() {
32 return Vec::new();
33 }
34 vec![Violation::new(
35 AIL002,
36 self.default_severity(),
37 doc.path.clone(),
38 "file is empty or contains only whitespace",
39 )]
40 }
41}