LinuxCommandLibrary

cargo-clippy

Rust linter for catching common mistakes

TLDR

Run clippy lints

$ cargo clippy
copy
Lint all targets
$ cargo clippy --all-targets
copy
Lint with all features
$ cargo clippy --all-features
copy
Fail on warnings (for CI)
$ cargo clippy -- -D warnings
copy
Allow specific lint
$ cargo clippy -- -A clippy::[lint_name]
copy
Warn on specific lint
$ cargo clippy -- -W clippy::[lint_name]
copy
Automatically fix issues
$ cargo clippy --fix
copy
Full CI check
$ cargo clippy --all-targets --all-features -- -D warnings
copy

SYNOPSIS

cargo clippy [options] [-- clippyoptions_]

DESCRIPTION

cargo clippy is the Rust linter that catches common mistakes and suggests improvements. Part of the Rust toolchain via rustup. Runs the default clippy::all lint group.

PARAMETERS

--all-targets

Lint all targets (lib, bin, tests, examples, benches)
--all-features
Enable all available features
--features features
Enable specified features
--release
Lint in release mode
--workspace
Lint all workspace members
--fix
Automatically apply suggested fixes
-- -A lint
Allow specified lint
-- -W lint
Warn on specified lint
-- -D lint
Deny specified lint (treat as error)

LINT GROUPS

clippy::correctness

Deny-by-default, catches outright bugs
clippy::style
Idiomatic code suggestions
clippy::complexity
Simplification suggestions
clippy::perf
Performance improvements
clippy::pedantic
Stricter, more opinionated lints

INSTALLATION

Included with Rust toolchain. Install/update via:

$ rustup component add clippy
copy

CAVEATS

Some lints are opinionated. Use lint configuration to customize for your project. The --fix option modifies files in place.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community