chore: lint test and bench targets with clippy - #770
Conversation
`lint:clippy` ran `cargo clippy --all --all-features -- -D warnings`, which covers lib and bin targets only. Tests and benches were never linted, so lint accumulated there unnoticed: turning `--all-targets` on surfaced 17 findings — 13 deprecated `criterion::black_box` calls in the bench, plus `clippy::unnecessary_get_then_check` and `clippy::manual_contains` in tests. Those were fixed in jdx#763, but nothing stops the same thing happening again while the gate stays narrow. mise runs both forms in CI (.github/workflows/test.yml): cargo clippy -- -D warnings cargo clippy --all-features --all-targets -- -D warnings and its AGENTS.md makes `cargo clippy --workspace --all-features --all-targets -- -D warnings` passing without `#[allow]` exclusions an explicit rule. This brings usage to the same bar. Newly covered: `lib/benches/parse.rs`, the integration tests under `lib/tests/`, `cli/tests/` and `clap_usage/tests/`, and every `#[cfg(test)] mod tests` — the last of which the lib target never enabled `cfg(test)` for. `lint-fix` is deliberately left alone. `render:usage-cli-completions` calls it for `cargo fmt` and `prettier -w`, and widening the `clippy --fix` inside it would add a full test and criterion build to `mise run render` for no benefit. mise keeps its fix side narrower than its check side for the same reason.
📝 WalkthroughWalkthroughThe ChangesClippy target coverage
Estimated code review effort: 1 (Trivial) | ~2 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThe PR broadens the Clippy lint gate to include test and benchmark targets.
Confidence Score: 5/5The PR appears safe to merge because the lint-only change introduces no actionable failure. The changed command broadens static-analysis coverage to workspace tests and benchmarks, while the repository configuration provides the corresponding targets and development dependencies. Important Files Changed
Reviews (1): Last reviewed commit: "chore: lint test and bench targets with ..." | Re-trigger Greptile |
Follow-up to #763, which fixed the lint but deliberately left the gate alone.
Problem
lint:clippyrunswhich covers lib and bin targets only. Tests and benches have never been linted. Nothing was watching them, so lint quietly accumulated: adding
--all-targetssurfaced 17 findings — 13 deprecatedcriterion::black_boxcalls inlib/benches/parse.rs, twoclippy::unnecessary_get_then_checkand twoclippy::manual_containsin tests. #763 fixed all of them, but the same drift starts again the moment someone writes a test.The
#[cfg(test)] mod testsblocks are the sharpest case: the lib target does not enablecfg(test), so unit tests are invisible to the current command no matter which crate they live in.Fix
One flag:
Newly covered:
lib/benches/parse.rs, the integration tests underlib/tests/,cli/tests/andclap_usage/tests/, and every#[cfg(test)] mod testsin the workspace.That is the entire diff — the current
mainalready passes--all-targetsclean, so this changes no source.Precedent
mise runs both forms in CI (
.github/workflows/test.yml):and its
AGENTS.mdstates it as a rule: refactor untilcargo clippy --workspace --all-features --all-targets -- -D warningspasses, without#[allow(clippy::…)]exclusions. This brings usage to the same bar.lint-fixleft alone, on purposerender:usage-cli-completionsends withmise run lint-fix, and what render needs from it iscargo fmtandprettier -w— theclippy --fixis along for the ride. Widening it would add a full test and criterion build to everymise run render, including the CI step that follows it with a no-diff assertion, for nothing render cares about.cargo fixalso has a known habit of bailing with "file has changed on disk" when one file is compiled as both a lib and a test target.mise makes the same split:
xtasks/lint-fix.ps1iscargo clippy --fix --allow-staged --allow-dirty -- -Dwarnings, without--all-targetsor even--all-features. Check wide, fix narrow.Cost
mise r lintis the last step of the test job, aftermise r buildandmise r test. Clippy does not share fingerprints withcargo build/cargo test, so the extra targets are compiled rather than reused. The genuinely new dependency is criterion, for the bench —coverage.ymlalready builds it viacargo test --all-features --all-targetsintasks/coverage.sh, but that is a different job with a different cache.Measured locally: 14 s warm on Windows, 1 m 22 s on Linux from a cache without criterion.
Verified
That the widened gate actually catches something, by planting a
clippy::clone_on_copyincli/tests/clap_sort.rs:Reverted afterwards.
mise run lint:clippyandmise run lint:fmtpass on the unmodified tree, on Windows and on Linux.Possible follow-up
mise runs a second, bare
cargo clippy -- -D warningsalongside the--all-featuresone, which catches code that only compiles with a feature enabled. usage has three features onusage-lib, so the same gap exists here. Left out because it is a question about features rather than targets.This pull request was generated by Claude Code.
Summary by CodeRabbit