Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

fix-clippy-warnings

БесплатноБез исполняемых скриптовНе проверен

Fix Rust Clippy warnings: apply the suggestion, or add a documented allow when it does not fit. Use when clippy reports warnings.

torrustот torrust★ 539 звёзд на GitHub

Об этом скилле

Fix Clippy Warnings

This skill guides you through the proper handling of Rust Clippy warnings in the Torrust Tracker project.

Clippy Philosophy

Always prefer fixing clippy warnings with the suggested approach rather than adding #[allow(...)] attributes. Clippy warnings are designed to improve code quality, readability, and maintainability.

When to Apply Clippy Suggestions

✅ Apply Suggested Fixes

When clippy suggests a specific code change that improves quality:

  • Use as_chunks::<N>() instead of chunks_exact(N) (as we did in SI-4)
  • Use #[allow(clippy::explicit_iter_loop)] instead of iter() when it's more concise
  • Apply any other suggestion that improves code quality

⚠️ When to Add Allowances

Only add #[allow(...)] when:

  1. The suggestion is not applicable to the specific use case
  2. The suggestion would break existing functionality or API
  3. The suggestion is temporarily ignored during a refactoring phase
  4. The suggestion is not yet supported in the current Rust version

How to Document Exceptions

When adding or modifying #[allow(clippy::...)] or #[expect(clippy::...)] attributes, use Rust's native reason parameter. The prospective Rust validator checks changed attributes against the branch merge base, so existing allows remain the separate remediation scope of #2158.

#[allow(
    clippy::unnecessary_wraps,
    reason = "Temporary parser compatibility shim; remove when #2158 is complete."
)]

The reason must be specific. A temporary reason must also contain either a stable issue reference such as #2158 or a non-empty remove when, remove after, remove by, removed when, removed after, removed by, or until condition. The validator treats temporary, temporarily, TODO, for now, and workaround as temporary wording and normalizes whitespace before checking the condition.

Do not enable clippy::allow_attributes_without_reason workspace-wide until #2158 has remediated the historical attributes that lack native reasons. It is the correct eventual compiler-aware enforcement mechanism, but enabling it now would violate this issue's prospective-baseline scope.

For a temporary item-level suppression, prefer #[expect(..., reason = "...")] when it is useful to learn that the underlying lint no longer fires. Do not force expect for crate-level policy.

The validator also checks changed cfg_attr(..., allow(clippy::...)) and cfg_attr(..., expect(clippy::...)) controls. Attributes written inside a macro_rules! token body are not visited by the Rust AST and are out of scope for this prospective check; do not use macros to conceal a lint suppression.

For example:

#[expect(
    clippy::unnecessary_wraps,
    reason = "Temporary parser compatibility shim; remove when #2158 is complete."
)]
fn parse_announce_response(data: &[u8]) -> Result<Response, ParseError> {
    // implementation
}

Common Clippy Patterns

Pattern 1: chunks_exact → as_chunks

Before:

for chunk in bytes.chunks_exact(6) {
    // process 6-byte chunks
}

After:

let (chunks, remainder) = bytes.as_chunks::<6>();
if !remainder.is_empty() {
    return Err(ParseError::InvalidChunkSize);
}
for chunk in chunks.iter() {
    // process 6-byte chunks
}

Pattern 2: Explicit Iterator Loop

Before:

for item in items.iter() {
    // process item
}

After:

for item in &items {
    // process item
}

Clippy Workflow

  1. Identify the warning: Run linter clippy to see specific clippy errors
  2. Apply suggestion: Try the suggested fix first
  3. Verify functionality: Ensure the change doesn't break existing behavior
  4. Document exceptions: Use the native reason = "..." parameter for changed Clippy allows
  5. Commit one lint at a time: make one atomic commit for each clippy lint type (for example one for explicit_iter_loop), name the lint in the message so the fix traces to its entry in the Clippy catalog, and follow commit-changes
  6. Run full linters: Confirm linter all passes

Related Skills

Полный SKILL.md на GitHub

Установить fix-clippy-warnings в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл fix-clippy-warnings?

Fix Rust Clippy warnings: apply the suggestion, or add a documented allow when it does not fit. Use when clippy reports warnings.

Как установить скилл fix-clippy-warnings?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл fix-clippy-warnings запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить fix-clippy-warnings с