pub struct Linter { /* private fields */ }Implementations§
Source§impl Linter
impl Linter
Sourcepub fn new(
settings: Settings,
interner: ThreadedInterner,
codebase: CodebaseReflection,
) -> Self
pub fn new( settings: Settings, interner: ThreadedInterner, codebase: CodebaseReflection, ) -> Self
Creates a new linter.
This method will create a new linter with the given settings and interner.
§Parameters
settings: The settings to use for the linter.interner: The interner to use for the linter, usually the same one used by the parser, and the module.codebase: The codebase reflection to use for the linter.
§Returns
A new linter.
Sourcepub fn with_all_plugins(
settings: Settings,
interner: ThreadedInterner,
codebase: CodebaseReflection,
) -> Self
pub fn with_all_plugins( settings: Settings, interner: ThreadedInterner, codebase: CodebaseReflection, ) -> Self
Creates a new linter with all plugins enabled.
This method will create a new linter with all plugins enabled. This is useful for when you want to lint a source with all available rules.
§Parameters
settings: The settings to use for the linter.interner: The interner to use for the linter, usually the same one used by the parser, and the module.codebase: The codebase reflection to use for the linter.
§Returns
A new linter with all plugins enabled.
Sourcepub fn add_plugin(&mut self, plugin: impl Plugin)
pub fn add_plugin(&mut self, plugin: impl Plugin)
Adds a plugin to the linter.
This method will add a plugin to the linter. The plugin will be enabled if it is enabled in the settings. If the plugin is not enabled in the settings, it will only be enabled if it is a default plugin.
§Parameters
plugin: The plugin to add to the linter.
Sourcepub fn add_rule(&mut self, plugin_slug: impl Into<String>, rule: Box<dyn Rule>)
pub fn add_rule(&mut self, plugin_slug: impl Into<String>, rule: Box<dyn Rule>)
Adds a rule to the linter.
This method will add a rule to the linter. The rule will be enabled if it is enabled in the settings.
§Parameters
plugin_slug: The slug of the plugin that the rule belongs to.rule: The rule to add to the linter.
Sourcepub fn get_configured_rules(&self) -> RwLockReadGuard<'_, Vec<ConfiguredRule>>
pub fn get_configured_rules(&self) -> RwLockReadGuard<'_, Vec<ConfiguredRule>>
Returns a read lock for the vector of ConfiguredRule instances maintained by the linter.
This method provides direct, read-only access to all currently configured rules.
You can iterate over them or inspect their fields (e.g., slug, level, etc.).
§Panics
If the underlying RwLock is poisoned (e.g. another thread panicked while holding
the lock), this method will panic with "Unable to get rule: poisoned lock".
Sourcepub fn get_rule_level(&self, slug: &str) -> Option<Level>
pub fn get_rule_level(&self, slug: &str) -> Option<Level>
Retrieves the level of a rule by its fully qualified slug.
This method looks up a configured rule by its slug (e.g., "plugin-slug/rule-slug")
and returns the rule’s current level (e.g., Level::Warning).
§Parameters
slug: The fully qualified slug of the rule (e.g."best-practices/excessive-nesting").
§Returns
An Option<Level>. Returns Some(Level) if the slug is found among the currently
configured rules, or None if no matching rule is found.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Linter
impl !RefUnwindSafe for Linter
impl Send for Linter
impl Sync for Linter
impl Unpin for Linter
impl !UnwindSafe for Linter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more