pub struct CustomRule {
pub code: String,
pub pattern: String,
pub message: String,
pub severity: Severity,
pub suggestion: Option<String>,
pub extensions: Vec<String>,
pub languages: Vec<String>,
pub enabled: bool,
}Expand description
A custom regex-based lint rule.
Fields§
§code: StringUnique rule code (e.g., “custom/no-fixme”).
pattern: StringRegex pattern to match in source code.
message: StringError message to display when pattern matches.
severity: SeveritySeverity level for this rule.
suggestion: Option<String>Optional suggestion for fixing the issue.
extensions: Vec<String>File extensions to check (e.g., [“rs”, “py”]). Empty means all files.
languages: Vec<String>Languages to check (e.g., [“rust”, “python”]). Empty means all languages.
enabled: boolWhether this rule is enabled.
Implementations§
Source§impl CustomRule
impl CustomRule
Sourcepub fn new(
code: impl Into<String>,
pattern: impl Into<String>,
message: impl Into<String>,
) -> Self
pub fn new( code: impl Into<String>, pattern: impl Into<String>, message: impl Into<String>, ) -> Self
Create a new custom rule with required fields.
Sourcepub fn with_severity(self, severity: Severity) -> Self
pub fn with_severity(self, severity: Severity) -> Self
Set the severity level.
Sourcepub fn with_suggestion(self, suggestion: impl Into<String>) -> Self
pub fn with_suggestion(self, suggestion: impl Into<String>) -> Self
Set the suggestion text.
Sourcepub fn with_extensions(self, extensions: Vec<String>) -> Self
pub fn with_extensions(self, extensions: Vec<String>) -> Self
Set the file extensions filter.
Sourcepub fn with_languages(self, languages: Vec<String>) -> Self
pub fn with_languages(self, languages: Vec<String>) -> Self
Set the languages filter.
Sourcepub fn applies_to_extension(&self, ext: &str) -> bool
pub fn applies_to_extension(&self, ext: &str) -> bool
Check if this rule applies to a given file extension.
Sourcepub fn applies_to_language(&self, lang: &str) -> bool
pub fn applies_to_language(&self, lang: &str) -> bool
Check if this rule applies to a given language.
Trait Implementations§
Source§impl Clone for CustomRule
impl Clone for CustomRule
Source§fn clone(&self) -> CustomRule
fn clone(&self) -> CustomRule
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CustomRule
impl Debug for CustomRule
Source§impl<'de> Deserialize<'de> for CustomRule
impl<'de> Deserialize<'de> for CustomRule
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
Auto Trait Implementations§
impl Freeze for CustomRule
impl RefUnwindSafe for CustomRule
impl Send for CustomRule
impl Sync for CustomRule
impl Unpin for CustomRule
impl UnsafeUnpin for CustomRule
impl UnwindSafe for CustomRule
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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