Skip to main content

Module rule

Module rule 

Source

Structs§

AiCheck
Optional AI confirmation step for a rule. When present, the rule’s rule AST pattern acts as a cheap pre-filter: matches become candidates that an LLM (or the System One classifier) must confirm before they are reported. The AST layer never executes this field; the AI pipeline in slopguard-ai reads it.
FixCase
One rewrite assertion for an autofixable rule: slopguard test applies the rule’s rewrite to before and requires the result to equal after. This is what proves a rewrite is correct, alongside should_match.
LanguageIter
An iterator over the variants of Language
Rule
RuleId
RuleTests

Enums§

Category
FixSafety
Whether an autofix preserves behavior. scan --fix applies Safe fixes; Unsafe ones also need --unsafe-fixes.
Language
ReasonMode
How the reason (the finding’s note) is produced when an ai_check rule fires. See AiCheck::reason.
RuleError
Severity

Functions§

is_rule_active
Whether a rule (builtin or external) takes part in a scan under config.
load_all_rules
Load all rules (builtin + custom + external sources) without filtering by activation status. Used by explain to look up any rule regardless of config, so an opt-in or disabled rule can still be explained.
load_builtin_rules
Load all builtin rules embedded via rust-embed.
load_custom_rules
Load rules from custom directories on the filesystem. Missing directories are skipped; subdirectories are searched recursively.
load_effective_rules
Load all effective rules based on config: builtin, custom rules from configured directories, and rules from resolved external sources, all filtered by is_rule_active (rulesets, enabled: false, and the enable/disable lists). An external rule reusing a builtin id is rejected before any filtering.
load_source_rules
Load rules from resolved external sources (git clones and local paths), stamping each rule with the source’s provenance. A source directory that is missing (e.g. a git path sub-directory that does not exist) is skipped.
parse_rule
Parse a single YAML string into a Rule, validating required fields.
read_fixture
Read a whole-file test fixture referenced by tests.should_match_files or tests.should_not_match_files. Builtin rules resolve against the embedded ruleset; custom rules resolve against the directory they were loaded from.
validate_unique_ids
Validate that all rule (id, language) pairs are unique. The same rule id may appear for different languages (e.g. no-todo-fixme for both Rust and TypeScript), so a single rules.disable entry covers both variants.