Useful Cargo plugins

1 min read

These are all good plugins to run in CI. Source: Zero to Production in Rust

cargo add

Add and remove crates to Cargo.toml

➜ cargo install cargo-edit

➜ cargo add actix-web
    Updating '' index
      Adding actix-web v3.3.2 to dependencies

➜ cargo add actix-rt --dev # Dev dependency

cargo tarpaulin

Measures test coverage.

As of May 2021, only works on Linux-x86.

➜ cargo install cargo-tarpaulin

➜ cargo tarpaulin --ignore-tests

cargo fmt

Format code automatically.

➜ rustup component add rustfmt

# Format entire project
➜ cargo fmt

# Run in CI. Fail the build if the code isn't formatted
➜ cargo fmt -- --check

cargo clippy

Get warnings and helpful tips à la Microsoft Clippy.

➜ rustup component add clippy

# Run on entire project
➜ cargo clippy

# Run in CI. Fail the build if there are any warnings
➜ cargo clippy -- -D warnings

cargo audit

Audit your dependencies for security issues.

Snippet ```bash ➜ cargo install cargo-audit

➜ cargo audit