pub struct Rule {Show 16 fields
pub id: String,
pub query_str: String,
pub severity: Severity,
pub message: String,
pub allow: Vec<Pattern>,
pub files: Vec<Pattern>,
pub source_path: PathBuf,
pub languages: Vec<String>,
pub enabled: bool,
pub builtin: bool,
pub requires: HashMap<String, String>,
pub fix: Option<String>,
pub tags: Vec<String>,
pub doc: Option<String>,
pub recommended: bool,
pub applies_in_tests: bool,
}Expand description
A syntax rule definition.
Fields§
§id: StringUnique identifier for this rule.
query_str: StringThe tree-sitter query pattern.
severity: SeveritySeverity level.
message: StringMessage to display when the rule matches.
allow: Vec<Pattern>Glob patterns for files where matches are allowed.
files: Vec<Pattern>Glob patterns for files where this rule applies (inclusion filter).
If non-empty, the rule only runs on files that match at least one pattern.
If empty, the rule runs on all files (subject to allow exclusions).
source_path: PathBufSource file path of this rule (empty for builtins).
languages: Vec<String>Languages this rule applies to (inferred from query or explicit).
enabled: boolWhether this rule is enabled.
builtin: boolWhether this is a builtin rule.
requires: HashMap<String, String>Conditions that must be met for this rule to apply. Format: { “namespace.key” = “value” } or { “namespace.key” = “>=value” }
fix: Option<String>Auto-fix template using capture names from the query.
Substitution syntax: $capture_name is replaced by the text of the named capture
(e.g. $fn_name), and $match is replaced by the entire matched node’s text.
An empty string means “delete the matched node entirely”.
None means the rule has no auto-fix.
Tags for grouping and filtering rules by concept (e.g. “debug-print”, “security”).
doc: Option<String>Documentation from the markdown comment block between frontmatter and query.
recommended: boolWhether this rule is recommended for most projects (catches real bugs, not style).
applies_in_tests: boolWhether this rule should fire inside language-specific test regions
(e.g. Rust #[cfg(test)] mod ... blocks). Defaults to false, meaning
findings inside those regions are dropped — appropriate for rules like
unwrap-in-impl or dbg-macro where panics/debug calls are expected
in test code. Style rules, complexity ratchets, and tag-convention
rules that should fire in tests can opt in by setting this to true.
Test-region detection is per-language and lives in
{lang}.test_regions.scm query files. Languages without such a file
have no AST-based test detection — path-based excludes (e.g.
**/tests/** or *_test.go) remain the only mechanism there.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Rule
impl RefUnwindSafe for Rule
impl Send for Rule
impl Sync for Rule
impl Unpin for Rule
impl UnsafeUnpin for Rule
impl UnwindSafe for Rule
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> 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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request