목차

, , , ,

Clippy / cargo clippy

일반적인 실수, 의심스러운 code, style, complexity, performance 문제를 검사하는 official Rust lint component.

Installation

rustup의 default profile에는 보통 포함된다. 빠져 있다면 현재 toolchain에 component를 추가한다.

rustup component add clippy
cargo clippy --version

Usage

cargo clippy [cargo-options] [-- lint-options]

Examples

cargo clippy
cargo clippy --all-targets --all-features
cargo clippy --workspace --all-targets --all-features -- -D warnings
cargo clippy --fix --allow-dirty --allow-staged
cargo clippy -- -W clippy::pedantic

Lint Groups

CI

cargo clippy --workspace --all-targets --all-features -- -D warnings
-D warnings는 compiler version이 올라가 새 lint가 추가될 때 기존 code의 CI를 깨뜨릴 수 있다. toolchain pinning과 update 정책을 함께 운영한다.

Fixes

cargo clippy –fix는 source를 수정할 수 있다. clean working tree에서 diff를 검토하며 실행하고, staged 또는 dirty file 허용 flag는 의도를 확인한 경우에만 사용한다.

Troubleshooting

Help

+ cargo clippy --help

로컬 실행 파일이 없어 live output을 수집하지 않았다.
cargo clippy --help
rustc -W help

+

See Also

History