Skip to main content

Rule

Trait Rule 

Source
pub trait Rule: Send + Sync {
    // Required methods
    fn code(&self) -> &'static str;
    fn name(&self) -> &'static str;
    fn description(&self) -> &'static str;
    fn explanation(&self) -> &'static str;
    fn groups(&self) -> &[RuleGroup];
    fn is_fixable(&self) -> bool;
    fn crawl_type(&self) -> CrawlType;
    fn eval(&self, ctx: &RuleContext<'_>) -> Vec<LintViolation>;

    // Provided method
    fn configure(&mut self, _settings: &HashMap<String, String>) { ... }
}
Expand description

Trait that all lint rules must implement.

Required Methods§

Source

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

Rule code, e.g. “LT01”.

Source

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

Human-readable name, e.g. “layout.spacing”.

Source

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

One-line description.

Source

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

Multi-sentence explanation for AI consumers.

Source

fn groups(&self) -> &[RuleGroup]

Rule group.

Source

fn is_fixable(&self) -> bool

Can this rule auto-fix violations?

Source

fn crawl_type(&self) -> CrawlType

Which segments should be visited.

Source

fn eval(&self, ctx: &RuleContext<'_>) -> Vec<LintViolation>

Evaluate the rule at the given context, returning violations.

Provided Methods§

Source

fn configure(&mut self, _settings: &HashMap<String, String>)

Configure the rule with key-value settings from config. Default implementation is a no-op.

Implementors§