RuleRegistry

Struct RuleRegistry 

Source
pub struct RuleRegistry { /* private fields */ }
Expand description

Registry for managing linting rules

Implementations§

Source§

impl RuleRegistry

Source

pub fn new() -> Self

Create a new empty registry

Source

pub fn register(&mut self, rule: Box<dyn Rule>)

Register a rule with the registry

Rules are stored in registration order and will be executed in the same order during document checking.

Source

pub fn rules(&self) -> &[Box<dyn Rule>]

Get all registered rules

Source

pub fn get_rule(&self, id: &str) -> Option<&dyn Rule>

Get a rule by ID

Returns the first rule with the matching ID, or None if no such rule exists.

Source

pub fn rule_ids(&self) -> Vec<&'static str>

Get all rule IDs

Returns a vector of all registered rule IDs in registration order.

Source

pub fn get_enabled_rules(&self, config: &Config) -> Vec<&dyn Rule>

Get rules that should be enabled based on configuration

This method applies configuration filters to determine which rules should actually run, considering:

  • Explicitly enabled/disabled rules
  • Rule deprecation status
  • Category-based filtering
Source

pub fn get_enabled_rules_with_overrides( &self, document: &Document, config: &Config, ) -> Vec<&dyn Rule>

Get rules that should be enabled based on configuration and rule overrides for a specific document

This method applies configuration filters and handles rule overrides:

  • Basic configuration filtering (enabled/disabled rules, deprecation, categories)
  • Rule override resolution (context-specific rules can override general rules)
Source

pub fn should_run_rule(&self, rule: &dyn Rule, config: &Config) -> bool

Check if a rule should run based on configuration and metadata

This implements the rule filtering logic that considers:

  1. Explicitly disabled rules (always excluded)
  2. Explicitly enabled rules (always included, with deprecation warnings)
  3. Category-based filtering (enabled/disabled categories)
  4. Default behavior (exclude deprecated rules unless explicitly enabled)
Source

pub fn check_document_optimized_with_config( &self, document: &Document, config: &Config, ) -> Result<Vec<Violation>>

Check a document with enabled rules using a single AST parse

Source

pub fn check_document_with_config( &self, document: &Document, config: &Config, ) -> Result<Vec<Violation>>

Check a document with enabled rules

Source

pub fn check_document_optimized( &self, document: &Document, ) -> Result<Vec<Violation>>

Check a document with all rules using a single AST parse

Source

pub fn check_document(&self, document: &Document) -> Result<Vec<Violation>>

Check a document with all rules

Source

pub fn len(&self) -> usize

Get the number of registered rules

Source

pub fn is_empty(&self) -> bool

Check if the registry is empty

Trait Implementations§

Source§

impl Default for RuleRegistry

Source§

fn default() -> Self

Create a new empty registry

Note: Unlike the original implementation, this does NOT register any default rules. This is intentional for the core library to remain rule-agnostic.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.