Struct ast_grep_config::RuleConfig
source · pub struct RuleConfig<L: Language> {
pub id: String,
pub message: String,
pub note: Option<String>,
pub severity: Severity,
pub language: L,
pub rule: SerializableRule,
pub fix: Option<String>,
pub constraints: Option<HashMap<String, SerializableMetaVarMatcher>>,
pub files: Option<Vec<String>>,
pub ignores: Option<Vec<String>>,
pub url: Option<String>,
pub metadata: Option<HashMap<String, String>>,
}Fields§
§id: StringUnique, descriptive identifier, e.g., no-unused-variable
message: StringMain message highlighting why this rule fired. It should be single line and concise, but specific enough to be understood without additional context.
note: Option<String>Additional notes to elaborate the message and provide potential fix to the issue.
severity: SeverityOne of: Info, Warning, or Error
language: LSpecify the language to parse and the file extension to includ in matching.
rule: SerializableRulePattern rules to find matching AST nodes
fix: Option<String>A pattern to auto fix the issue. It can reference metavariables appeared in rule.
constraints: Option<HashMap<String, SerializableMetaVarMatcher>>Addtional meta variables pattern to filter matching
files: Option<Vec<String>>Glob patterns to specify that the rule only applies to matching files
ignores: Option<Vec<String>>Glob patterns that exclude rules from applying to files
url: Option<String>Documentation link to this rule
metadata: Option<HashMap<String, String>>Extra information for the rule
Implementations§
source§impl<L: Language> RuleConfig<L>
impl<L: Language> RuleConfig<L>
pub fn get_matcher(&self) -> RuleWithConstraint<L>
pub fn get_fixer(&self) -> Option<Pattern<L>>
pub fn get_meta_var_matchers(&self) -> MetaVarMatchers<L>
pub fn get_message(&self, node: &NodeMatch<'_, L>) -> String
Trait Implementations§
source§impl<L: Clone + Language> Clone for RuleConfig<L>
impl<L: Clone + Language> Clone for RuleConfig<L>
source§fn clone(&self) -> RuleConfig<L>
fn clone(&self) -> RuleConfig<L>
Returns a copy 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<'de, L> Deserialize<'de> for RuleConfig<L>where
L: Deserialize<'de> + Language,
impl<'de, L> Deserialize<'de> for RuleConfig<L>where
L: Deserialize<'de> + Language,
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