Skip to main content

Rule

Trait Rule 

Source
pub trait Rule: Send + Sync {
    // Required methods
    fn id(&self) -> RuleId;
    fn default_severity(&self) -> Severity;
    fn description(&self) -> &'static str;
    fn fix_hint(&self) -> &'static str;
    fn run(&self, doc: &ParsedDocument, ctx: &RuleContext<'_>) -> Vec<Violation>;

    // Provided method
    fn applies_to(&self, file_type: FileType) -> bool { ... }
}
Expand description

Trait implemented by every per-document lint rule.

Required Methods§

Source

fn id(&self) -> RuleId

This rule’s stable identifier.

Source

fn default_severity(&self) -> Severity

Severity when no config override applies.

Source

fn description(&self) -> &'static str

One-line human description of what the rule enforces. Reporters show this once per rule group so an auditor knows why it fired.

Source

fn fix_hint(&self) -> &'static str

One-line suggested remediation. Empty string means the rule has no generic hint (the caller should look at the finding detail instead).

Source

fn run(&self, doc: &ParsedDocument, ctx: &RuleContext<'_>) -> Vec<Violation>

Inspect one document and return any findings.

Provided Methods§

Source

fn applies_to(&self, file_type: FileType) -> bool

Whether this rule should run against files of the given type. Defaults to “AI guidance files only” — rules that also apply to generic Markdown / YAML must override this.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§