slopguard-rules
Embedded builtin rule definitions for slopguard. YAML rules compiled into the binary at build time via rust-embed.
For the CLI tool, see slopguard-cli. For the full project, see the main README.
Rule Structure
rules/
slop/ # AI-generated code patterns
security/ # Security anti-patterns
correctness/ # Error handling, type safety
Accessing Embedded Rules
The crate exposes a single struct BuiltinRules that implements rust_embed::Embed:
use BuiltinRules;
use Embed;
// List all embedded rule files
for file in iter
// Read a specific rule
if let Some = get
In practice, you do not need to use this crate directly. slopguard-core handles rule loading through load_builtin_rules() and load_effective_rules().
Rule Format
Each YAML file follows the ast-grep rule format with slopguard extensions:
id: no-unwrap-in-prod
language: rust
severity: error
category: correctness
message: ".unwrap() forbidden in production."
note: "unwrap() crashes the process on a single invalid input."
rule:
pattern: $X.unwrap()
skip_test_code: true
tests:
should_match:
- "let x = foo().unwrap();"
should_not_match:
- "let x = foo()?;"
See RULES.md for detailed documentation on all builtin rules.
License
MIT - see LICENSE.