pub struct Linter { /* private fields */ }Expand description
A compiled, ready-to-run rule set.
Implementations§
Source§impl Linter
impl Linter
Sourcepub fn new(config: Config, callbacks: &Callbacks) -> Result<Self, ConfigError>
pub fn new(config: Config, callbacks: &Callbacks) -> Result<Self, ConfigError>
Compiles a config into a linter, resolving every rule’s callback
and parser against callbacks. Errors when a rule references a
callback or parser that is not registered — patterns themselves
were validated at config-load time.
Sourcepub fn lint(&self, source: &str) -> Vec<Violation>
pub fn lint(&self, source: &str) -> Vec<Violation>
Lints one snapshot of a source file with the global rules only — scoped rules are ignored. Hits are sorted by position (then span end, then rule id) so output is deterministic regardless of rule order. Zero-width matches are skipped.
Sourcepub fn lint_in(&self, info: DocInfo<'_>, source: &str) -> Vec<Violation>
pub fn lint_in(&self, info: DocInfo<'_>, source: &str) -> Vec<Violation>
Like Linter::lint, with file path and language exposed to
callbacks.
Sourcepub fn lint_segments(
&self,
source: &str,
segments: &[(usize, Span)],
) -> Vec<Violation>
pub fn lint_segments( &self, source: &str, segments: &[(usize, Span)], ) -> Vec<Violation>
Lints pre-computed scope regions — the subpasses. segments are
(scope index, region) pairs, typically from scopes::segment_all
or a parse tree’s scoped nodes.
Sourcepub fn lint_segments_in(
&self,
info: DocInfo<'_>,
source: &str,
segments: &[(usize, Span)],
) -> Vec<Violation>
pub fn lint_segments_in( &self, info: DocInfo<'_>, source: &str, segments: &[(usize, Span)], ) -> Vec<Violation>
Like Linter::lint_segments, with file path and language
exposed to callbacks.
Sourcepub fn lint_merged(
&self,
source: &str,
segments: &[(usize, Span)],
) -> Vec<Violation>
pub fn lint_merged( &self, source: &str, segments: &[(usize, Span)], ) -> Vec<Violation>
Global rules plus scoped rules over segments, merged and sorted —
one call for consumers that already have regions (e.g. a parse
tree).
Sourcepub fn lint_merged_in(
&self,
info: DocInfo<'_>,
source: &str,
segments: &[(usize, Span)],
) -> Vec<Violation>
pub fn lint_merged_in( &self, info: DocInfo<'_>, source: &str, segments: &[(usize, Span)], ) -> Vec<Violation>
Like Linter::lint_merged, with file path and language exposed
to callbacks.
Sourcepub fn lint_all(&self, source: &str) -> Vec<Violation>
pub fn lint_all(&self, source: &str) -> Vec<Violation>
Segments the source itself, then lints everything — the one-liner for CLI use.
Sourcepub fn lint_all_in(&self, info: DocInfo<'_>, source: &str) -> Vec<Violation>
pub fn lint_all_in(&self, info: DocInfo<'_>, source: &str) -> Vec<Violation>
Like Linter::lint_all, with file path and language exposed to
callbacks.