This project enforces zero-tolerance for bad code through multiple automated layers. If any of these fail, your code will not compile, commit, or merge.
# Cargo.toml — these are set to DENY, not warn
clippy::all + clippy::pedantic + clippy::nursery = deny// lib.rs — crate-level enforcement (library root used for benchmarks)
#![deny(unsafe_code)]
// Lints are configured in Cargo.toml [lints.clippy] and [lints.rust] sections.
// unsafe_code is denied globally; modules that need FFI get #[allow(unsafe_code)]What this means: Clippy won't just warn you — it will refuse to compile your code if it finds lint violations. Clippy lints at deny level mean compile errors, not warnings.
Install once after cloning:
.\scripts\install-hooks.ps1Before every commit, this automatically runs:
cargo fmt --check— formattingcargo clippy— all lints at deny levelcargo test— all tests must pass
If any step fails, the commit is rejected.
Additionally, a commit-msg hook validates that all commit messages follow Conventional Commits format:
<type>(<optional-scope>): <lowercase description>
Allowed types: feat, fix, docs, style, refactor, perf, test,
build, ci, chore, revert, enforce.
Every pull request to main runs 7 gates across two jobs:
quality-gate job:
- Formatting —
cargo fmt --check - Clippy — deny-level lints with
RUSTFLAGS="-D warnings" - Tests —
cargo test --locked --all-targets - Bench compile —
cargo bench --locked --no-run(benchmarks must compile) - Debug build —
cargo build --locked(binary compiles) - Documentation —
cargo docwith-D warningsand strict rustdoc lints
audit job:
7. Dependency audit — cargo deny check
- Only MIT/Apache-2.0/BSD/MPL-2.0 licenses allowed
- Known-vulnerable crates are denied
- Only crates.io sources (no random git repos)
- Duplicate dependency versions flagged
# Format your code
cargo fmt
# Check for lint issues (will error, not warn)
cargo clippy
# Run tests
cargo test
# Full release build
cargo build --release
# Audit dependencies (optional, requires cargo-deny)
cargo deny checkunsafeis#![deny]at crate level- Individual modules that need FFI get
#[allow(unsafe_code)]on themoddeclaration - Every
unsafe {}block must have a// SAFETY:comment explaining why it's sound - Never add new
unsafewithout reviewing the invariants
| You try to... | What happens |
|---|---|
| Leave an unused variable | Compile error (deny(unused_variables)) |
| Add dead code | Compile error (deny(dead_code)) |
| Skip formatting | Commit rejected (pre-commit hook) |
Use dbg!() |
Compile error (clippy disallowed-macros) |
Use todo!() |
Compile error (clippy disallowed-macros) |
| Write a 150-line function | Compile error (too_many_lines at deny level) |
Ignore a Result |
Compile error (deny(unused_must_use)) |
Add unsafe in a safe module |
Compile error (deny(unsafe_code)) |
| Add a GPL dependency | cargo deny rejects it |
| Push without tests passing | CI blocks the merge |