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★ 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 ofchunks_exact(N)(as we did in SI-4) - Use
#[allow(clippy::explicit_iter_loop)]instead ofiter()when it's more concise - Apply any other suggestion that improves code quality
⚠️ When to Add Allowances
Only add #[allow(...)] when:
- The suggestion is not applicable to the specific use case
- The suggestion would break existing functionality or API
- The suggestion is temporarily ignored during a refactoring phase
- 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
- Identify the warning: Run
linter clippyto see specific clippy errors - Apply suggestion: Try the suggested fix first
- Verify functionality: Ensure the change doesn't break existing behavior
- Document exceptions: Use the native
reason = "..."parameter for changed Clippy allows - 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 followcommit-changes - Run full linters: Confirm
linter allpasses
Related Skills
run-linters- Run all code quality checkscommit-changes- Commit changes with proper conventions
Установить 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), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic