Linter

Struct Linter 

Source
pub struct Linter { /* private fields */ }

Implementations§

Source§

impl Linter

Source

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.

Source

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.

Source

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.
Source

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.
Source

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".

Source

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.

Source

pub fn lint(&self, module: &Module) -> IssueCollection

Lints the given module.

This method will lint the given module and return a collection of issues.

§Parameters
  • module: The module to lint.
§Returns

A collection of issues.

Trait Implementations§

Source§

impl Clone for Linter

Source§

fn clone(&self) -> Linter

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Linter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more