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 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 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§