repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-merge-conflict
name: Dectect merge conflicts
- id: end-of-file-fixer
name: Fix end of file
- id: trailing-whitespace
name: Delete trailing whitespace
- id: mixed-line-ending
name: Check end of line
args: ["--fix=lf"]
- id: check-case-conflict
name: Check case conflict
- repo: https://github.com/doublify/pre-commit-rust
rev: v1.0
hooks:
- id: fmt
name: Format with rustfmt
args: ["--manifest-path", "Cargo.toml", "--", "--check"]
- id: cargo-check
name: Check compilation
args: ["--all-features"]
- id: clippy
name: Check with Clippy
args: ["--all-targets", "--all-features", "--", "-D", "warnings"]
- repo: local
hooks:
- id: cargo-llvm-cov
name: Execute test with coverage
entry: bash -c 'TERM=dumb cargo llvm-cov --all-features --workspace --color=never'
language: system
types: [rust]
pass_filenames: false
environment:
TERM: dumb
- id: cargo-doc
name: Check documentation
entry: cargo doc
language: system
types: [rust]
pass_filenames: false
args: ["--no-deps", "--document-private-items", "--all-features"]
- id: cargo-audit
name: Security audit
entry: bash -c 'if command -v cargo-audit &> /dev/null; then cargo audit; else echo "⚠️ cargo-audit not installed, skip security audit"; fi'
language: system
types: [rust]
pass_filenames: false
verbose: true
- id: cargo-udeps
name: unused dependencies
entry: bash -c '
if rustup toolchain list | grep -q nightly; then
echo "🔍 Check unused dependencies with nightly..."
cargo +nightly udeps --all-targets;
else
echo "⚠️ Toolchain nightly not installed, skip cargo-udeps";
fi '
language: system
types: [rust]
pass_filenames: false
verbose: true
- id: no-debug-prints
name: Detection of println! and dbg!
entry: bash -c 'if git diff --cached --name-only | grep "\.rs$" | xargs grep -n "println!\|dbg!" 2>/dev/null; then echo "⚠️ println! or dbg! detected"; exit 1; fi'
language: system
types: [rust]
pass_filenames: false
- id: cargo-lock
name: Check Cargo.lock
entry: cargo update --dry-run
language: system
types: [rust]
pass_filenames: false
default_install_hook_types: [pre-commit, pre-push]
default_stages: [commit]
exclude: |
(?x)^(
target/|
.git/|
.cargo/|
.*/frames/.*\.adoc$
)$
ci:
autofix_commit_msg: |
[pre-commit.ci] auto fixes from pre-commit hooks
autofix_prs: true
autoupdate_branch: ""
autoupdate_commit_msg: "[pre-commit.ci] pre-commit autoupdate"
autoupdate_schedule: weekly
skip: []
submodules: false