codestyle
A code style checker and formatter for Rust that enforces opinionated conventions beyond what rustfmt and clippy provide.
Cargo
From source
Usage
Basic usage
# Check for violations
# Auto-fix violations
Check options
Each check can be enabled or disabled with --<check>=true|false:
# Enable instrument check (off by default)
# Disable specific checks
Available flags
| Flag | Default | Description |
|---|---|---|
--instrument |
false | Check async functions for #[instrument] |
--loops |
true | Check endless loops for //LOOP comments |
--impl-follows-type |
true | Check impl blocks follow type definitions |
--embed-simple-vars |
true | Check format strings embed simple variables |
--insta-inline-snapshot |
true | Check insta macros use inline snapshots |
Format mode
Format mode will:
- Automatically fix violations where possible
- Delete any
.snapand.pending-snapfiles (when insta check enabled) - Report violations that require manual fixing
# codestyle: fixed 3 violation(s)
# codestyle: 1 violation(s) need manual fixing:
# [loops] src/main.rs:42:5: Endless loop without //LOOP comment