Skip to main content

Rule

Struct Rule 

Source
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: String

Unique identifier for this rule.

§query_str: String

The tree-sitter query pattern.

§severity: Severity

Severity level.

§message: String

Message 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: PathBuf

Source file path of this rule (empty for builtins).

§languages: Vec<String>

Languages this rule applies to (inferred from query or explicit).

§enabled: bool

Whether this rule is enabled.

§builtin: bool

Whether 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: Vec<String>

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: bool

Whether this rule is recommended for most projects (catches real bugs, not style).

§applies_in_tests: bool

Whether 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§

Source§

impl Debug for Rule

Source§

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

Formats the value using the given formatter. Read more

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> 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> 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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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