pub struct Rule {
pub id: String,
pub name: String,
pub severity: Severity,
pub category: Option<String>,
pub query: PatternQuery,
pub message: String,
pub suggestion: Option<String>,
pub scope: Vec<String>,
pub fix: Option<Value>,
}Expand description
Lint rule definition with optional fix
Fields§
§id: StringUnique identifier (e.g., “RL001”)
name: StringHuman-readable name
severity: SeveritySeverity level
category: Option<String>Category for grouping
query: PatternQueryDetection query
message: StringError message (supports variable interpolation)
suggestion: Option<String>Suggestion text (human-readable hint, not executable)
scope: Vec<String>Target code scopes where this rule applies.
When non-empty, the rule only fires on symbols within the specified scopes. Valid values: “lib”, “bin”, “test”. When empty (default), the rule applies to all scopes.
scope: [lib] # Library code only
scope: [lib, bin] # Production code (lib + bin)fix: Option<Value>Fix specification (Intent or MutationSpec as JSON)
Default format is Intent (public DSL):
fix:
type: UnwrapToQuestion
target_fn: "$MATCH"For builtin rules, MutationSpec can be used with _kind: mutation_spec:
fix:
_kind: mutation_spec
type: UnwrapToQuestion
target: ...Implementations§
Source§impl Rule
impl Rule
Sourcepub fn new(
id: impl Into<String>,
name: impl Into<String>,
severity: Severity,
query: PatternQuery,
message: impl Into<String>,
) -> Self
pub fn new( id: impl Into<String>, name: impl Into<String>, severity: Severity, query: PatternQuery, message: impl Into<String>, ) -> Self
Create a new rule
Sourcepub fn with_category(self, category: impl Into<String>) -> Self
pub fn with_category(self, category: impl Into<String>) -> Self
Set category
Sourcepub fn with_suggestion(self, suggestion: impl Into<String>) -> Self
pub fn with_suggestion(self, suggestion: impl Into<String>) -> Self
Set suggestion
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Rule
impl<'de> Deserialize<'de> for Rule
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl JsonSchema for Rule
impl JsonSchema for Rule
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreimpl StructuralPartialEq for Rule
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
Mutably borrows from an owned value. Read more