mcpField
C
clippy-advanced

clippy-advanced

github.com/laurigatesテスト・品質59106 回インストール1 日前に更新
リポジトリ

clippy-advanced について

Rust 開発者向けの Clippy 設定ガイドで、リンティングの分類、カスタムルール、禁止項目、IDE 連携と CI チェックを扱います。コード規約の策定と維持を目的とし、フォーマット、ビルド、テストには使いません。

主な機能

  1. 01リンティング分類とレベルの設定
  2. 02clippy.toml のしきい値と禁止項目の設定
  3. 03Cargo ワークスペースの lint 設定
  4. 04CI チェックと出力形式の設定
  5. 05lint 抑制ルールの管理

活用シーン

  1. 01Rust プロジェクトのコード規約策定
  2. 02CI で lint 警告をエラーとして扱う
  3. 03プロジェクトで pedantic チェックを有効化

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/laurigates/claude-plugins --skill clippy-advanced

インストール後、Claude Code で/clippy-advancedを入力して読み込まれたか確認します。

同梱ファイルREFERENCE.md

詳細

clippy-advanced - 高度な Clippy 設定

カスタムルール、Lint カテゴリ、使用禁止メソッド、IDE 連携を含む、包括的な Rust Lint のための高度な Clippy 設定です。

このスキルを使用する場面

このスキルを使用する場面...代わりに別のツールを使用する場面...
Clippy の Lint ルールを設定するコードをフォーマットする(rustfmt を使用)
Rust の CI Lint を設定するビルド/コンパイルする(cargo build を使用)
clippy.toml をカスタマイズするテストを実行する(cargo test を使用)
コード規約を適用する依存関係を管理する(cargo add を使用)

インストール

# Clippy is included with rustup
rustup component add clippy

# Verify installation
cargo clippy --version

# Update clippy with rust toolchain
rustup update

基本的な使い方

# Run clippy on current project
cargo clippy

# Run on all targets (lib, bins, tests, examples, benches)
cargo clippy --all-targets

# Run with all features enabled
cargo clippy --all-features

# Run on workspace
cargo clippy --workspace --all-targets --all-features

# Show detailed lint explanations
cargo clippy -- -W clippy::all -A clippy::pedantic

# Treat warnings as errors
cargo clippy -- -D warnings

Lint カテゴリ

カテゴリ目的デフォルト
clippy::correctnessバグの可能性拒否
clippy::complexity複雑すぎるコード警告
clippy::perfパフォーマンスの問題警告
clippy::styleコードスタイル警告
clippy::suspicious誤りに見えるコード警告
clippy::pedantic独自の見解に基づくスタイルオフ
clippy::restrictionオプトインの制約オフ
clippy::nursery実験的な機能オフ
clippy::cargoCargo.toml の問題オフ
推奨される Cargo.toml の設定
[workspace.lints.clippy]
# Deny correctness issues (likely bugs)
correctness = "deny"
complexity = "warn"
perf = "warn"
style = "warn"
suspicious = "warn"

# Enable pedantic but allow some noisy lints
pedantic = "warn"
must_use_candidate = "allow"
missing_errors_doc = "allow"

# Enable some restriction lints selectively
clone_on_ref_ptr = "warn"
dbg_macro = "warn"
print_stdout = "warn"
todo = "warn"
unimplemented = "warn"
unwrap_used = "warn"

# Enable nursery lints (experimental)
use_self = "warn"

clippy.toml の必須設定

しきい値と使用禁止項目を設定するため、プロジェクトのルートに clippy.toml を作成します。

cognitive-complexity-threshold = 15
too-many-lines-threshold = 100
too-many-arguments-threshold = 5

disallowed-methods = [
  { path = "std::env::var", reason = "Use std::env::var_os for better Unicode handling" },
  { path = "std::process::exit", reason = "Use Result propagation instead" },
]

disallowed-names = ["foo", "bar", "baz"]

Lint の抑制

// Function-level
#[allow(clippy::too_many_arguments)]
fn complex_function(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32) {}

// Module-level (src/lib.rs)
#![warn(clippy::all)]
#![warn(clippy::pedantic)]
#![deny(clippy::unwrap_used)]
#![allow(clippy::module_name_repetitions)]

// Inline
#[allow(clippy::cast_possible_truncation)]
let x = value as u8;

エージェント向けの最適化

コンテキストコマンド
CI で厳格にチェックcargo clippy --workspace --all-targets -- -D warnings
JSON 出力cargo clippy --message-format=json
コンパクトなエラーcargo clippy --message-format=short
クイックチェックcargo clippy --message-format=short -- -D warnings
Pedantic チェックcargo clippy -- -W clippy::pedantic -D clippy::correctness

クイックリファレンス

コマンドラインフラグ
フラグ説明
--all-targetsライブラリ、バイナリ、テスト、サンプル、ベンチマークをチェック
--all-featuresすべての機能を有効化
--workspaceワークスペース全体をチェック
--message-format=jsonツール向けの JSON 出力
--message-format=shortコンパクトなエラー形式
-- -D warnings警告をエラーとして扱う
-- -W clippy::pedanticPedantic Lint を有効化
-- -A clippy::lint_name特定の Lint を許可
Lint レベル
レベル属性効果
許可#[allow(...)]Lint を抑制
警告#[warn(...)]警告を表示
拒否#[deny(...)]コンパイルエラー

参考資料

詳細な設定例、CI 連携、IDE のセットアップ、ベストプラクティスについては、REFERENCE.md を参照してください。

コメント