{{tag>[cli rust clippy lint static-analysis]}}
====== 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]
* ''**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 =====
* ''clippy::correctness'': 명백히 잘못되거나 쓸모없는 code. 기본 deny.
* ''clippy::suspicious'', ''clippy::style'', ''clippy::complexity'', ''clippy::perf'': 기본 lint set의 주요 그룹.
* ''clippy::pedantic'': 더 엄격하며 false positive 가능성이 있어 선택적으로 적용.
* ''clippy::nursery'': 개발 중인 lint이므로 version 변화 가능성을 고려.
* ''clippy::cargo'': ''Cargo.toml'' 관련 lint.
* ''clippy::restriction'': 서로 충돌하거나 일반 code를 과도하게 제한할 수 있어 전체 그룹 활성화를 피하고 개별 lint를 선택한다.
===== 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 =====
* macro expansion이나 generated code의 false positive는 lint를 전역으로 끄기 전에 가장 좁은 scope의 ''#[allow(...)]''와 근거 comment를 검토한다.
* workspace package별 feature 차이는 실제 release 조합과 ''--all-features'' 결과를 모두 확인한다.
* nightly toolchain에서 component가 unavailable이면 compatible nightly date를 선택하거나 stable Clippy를 사용한다.
===== Help =====
+++ cargo clippy --help |
로컬 실행 파일이 없어 live output을 수집하지 않았다.
cargo clippy --help
rustc -W help
+++
===== See Also =====
* [[rust:ko]]
* [[rust:cargo:ko]]
* [[rust:rustfmt:ko]]
* [[https://doc.rust-lang.org/clippy/|Clippy Documentation]]
===== History =====
* codex:: 2026-07-20 Added Clippy lint groups, CI policy, automatic fix safety, and troubleshooting guidance.
{{indexmenu>.#1|js}}