pub struct RuleRegistry { /* private fields */ }Expand description
Registry for managing linting rules
Implementations§
Source§impl RuleRegistry
impl RuleRegistry
Sourcepub fn register(&mut self, rule: Box<dyn Rule>)
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.
Sourcepub fn get_rule(&self, id: &str) -> Option<&dyn Rule>
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.
Sourcepub fn rule_ids(&self) -> Vec<&'static str>
pub fn rule_ids(&self) -> Vec<&'static str>
Get all rule IDs
Returns a vector of all registered rule IDs in registration order.
Sourcepub fn get_enabled_rules(&self, config: &Config) -> Vec<&dyn Rule>
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
Sourcepub fn get_enabled_rules_with_overrides(
&self,
document: &Document,
config: &Config,
) -> Vec<&dyn Rule>
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)
Sourcepub fn should_run_rule(&self, rule: &dyn Rule, config: &Config) -> bool
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:
- Explicitly disabled rules (always excluded)
- Explicitly enabled rules (always included, with deprecation warnings)
- Category-based filtering (enabled/disabled categories)
- Default behavior (exclude deprecated rules unless explicitly enabled)
Sourcepub fn check_document_optimized_with_config(
&self,
document: &Document,
config: &Config,
) -> Result<Vec<Violation>>
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
Sourcepub fn check_document_with_config(
&self,
document: &Document,
config: &Config,
) -> Result<Vec<Violation>>
pub fn check_document_with_config( &self, document: &Document, config: &Config, ) -> Result<Vec<Violation>>
Check a document with enabled rules
Sourcepub fn check_document_optimized(
&self,
document: &Document,
) -> Result<Vec<Violation>>
pub fn check_document_optimized( &self, document: &Document, ) -> Result<Vec<Violation>>
Check a document with all rules using a single AST parse