// PART 02
Cargo tools
Cargo and a small set of extensions cover the quality workflow. This page lists what the repository actually uses, plus the ecosystem tools that are useful but not wired into CI.
Used daily in this repository
| Tool | Command | Role |
|---|---|---|
| cargo | cargo check -p <crate> |
fast syntax/type gate; run in the background, never synchronously |
| clippy | cargo clippy --workspace |
lint gate — must pass with 0 warnings; #[allow] is forbidden, fix the code |
| rustfmt | cargo fmt / cargo fmt --check |
formatting |
| cargo test | cargo test -p <crate> |
unit + integration tests |
| cargo tree | cargo tree --duplicates |
find duplicated dependencies |
| cargo audit | cargo audit |
dependency vulnerability scan — run weekly |
| cargo machete | cargo machete |
unused dependencies |
| cargo watch | cargo watch -x build |
auto-rebuild on change (optional, dev convenience) |
Repository-specific scripts complement these (scripts/):
verify-rust-syntax.sh [base-ref] is a quick syntax gate for changed files;
check_clippy_baseline.py tracks the clippy debt baseline; check_coverage.py
and check_dependency_pins.py enforce coverage goals and version pinning rules.
Coverage
The coverage gate is scripts/check_coverage.py; the working target is 80%+
on critical paths, with all error paths and security guards tested. Ecosystem
tools, if you want line-level reports locally:
cargo install cargo-tarpaulin # or cargo-llvm-cov
cargo tarpaulin --out Html # HTML report
cargo llvm-cov --html
Neither tarpaulin nor llvm-cov is wired into the repository’s CI; treat them as optional local instruments.
Security auditing
cargo install cargo-audit
cargo audit # RustSec advisories for Cargo.lock
cargo audit --json > /tmp/audit.json
Run weekly (the dependency-management rule) and only update dependencies
through a reviewed change: application crates track Cargo.lock, critical
crypto/security dependencies use exact version pins.
Dependency analysis
cargo tree # full graph
cargo tree --duplicates # multiple versions of the same crate
cargo tree --invert tokio # why is this dep here
cargo machete # unused dependencies
Binary-size analysis (cargo bloat --release --crates) is useful when the
release profile changes; it is not part of routine work.
Profiles to know
| Profile | Setting that matters |
|---|---|
| dev | jobs = 3 from .cargo/config.toml; clang + mold linker; incremental |
| release | opt-level = "z", lto = true, codegen-units = 1, strip = true, panic = "abort" |
Rules that make the tools matter
- No
#[allow(clippy::...)]— fix the code or delete it. - No
unwrap/expect/panic!outside tests — the no-panic rule is why clippy warnings are release blockers. - Exact pins for critical dependencies (crypto, security); caret ranges are acceptable for ordinary libraries.
cargo auditweekly, results reviewed as issues, not silently ignored.
What is deliberately not documented here
Generic cargo tutorials (installing via cargo install, configuring
registries, cross-compilation recipes) are upstream Cargo documentation. This
page records only the tools the repository’s own quality process invokes.