chore: pass clippy --all-targets and enforce it in CI#119
Merged
Conversation
Resolve the pre-existing clippy `--all-targets` debt so the strict gate (`cargo clippy --workspace --all-targets --all-features -- -D warnings`) exits 0, then tighten CI to keep it that way. No runtime behavior changes. Lints resolved (33 total under clippy 1.96.0): - default_trait_access (13): use concrete `zip::write::FileOptions::default()` instead of `Default::default()` in archive/reader.rs tests. - manual_contains (1): `declared.contains(&"unknown")` in conformance.rs. - module_inception (1): remove the redundant inner `mod tests` wrapper in document/tests.rs (the file is already the `tests` module); pure dedent, contents byte-identical after whitespace removal. - similar_names (18): scoped `#[allow]` on the three key-wrapping test modules in security/encryption.rs, where the `wrapper`/`wrapped` pairing is the natural and readable idiom. CI: change the clippy invocations in ci.yml (workspace + swift-bridge) and publish.yml from `--all-features` to `--all-targets --all-features` so test, bench, and example targets are linted going forward.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The strict clippy gate
cargo clippy --workspace --all-targets --all-features -- -D warningspreviously failed with 33 lints (all in test code, surfaced because#![warn(clippy::pedantic)]is enabled at the crate roots). CI only ran clippy without--all-targets, so this debt was invisible. This PR resolves every lint and tightens CI so the--all-targetsgate is enforced from now on. No runtime behavior changes.The clippy invocations are changed from
--all-featuresto--all-targets --all-features, so test/bench/example targets are now linted. Affected steps:.github/workflows/ci.yml--all-features→--all-targets --all-features.github/workflows/ci.yml--all-targets.github/workflows/publish.yml--all-features→--all-targets --all-featuresFuture PRs that introduce lints in test/bench/example code will now be caught.
Lint count: 33 → 0
Under clippy 1.96.0 (the toolchain in this environment), the
--all-targetsgate emitted exactly 33 lints. (The original estimate of ~41 includedneedless_pass_by_value; that pedantic lint does not fire under 1.96.0, confirmed by a cold re-lint at exit 0.)default_trait_accesssimilar_names#[allow](justified)module_inceptionmanual_contains15 fixed via real code changes · 18 scoped-allowed with reasons · 0 crate-level blanket allows.
Fixed (real, idiomatic changes)
default_trait_access×13 —cdx-core/src/archive/reader.rs(tests): replacedDefault::default()with the concretezip::write::FileOptions::default()instart_file::<&str, ()>(..)calls. The turbofish already pins the type, so this is a no-op at runtime.manual_contains×1 —cdx-core/tests/conformance.rs:declared.iter().any(|n| *n == "unknown")→declared.contains(&"unknown").module_inception×1 —cdx-core/src/document/tests.rs: removed the redundant innermod tests { .. }wrapper. The file is loaded by#[cfg(test)] mod tests;indocument/mod.rs, so it is thetestsmodule; the innermod testswas pointless nesting. This is a pure dedent — the file's non-whitespace bytes are byte-identical before and after (verified withcmp), so no#[allow]was needed and nothing semantic changed.Scoped-allowed (with justification)
similar_names×18 —cdx-core/src/security/encryption.rs: a module-scoped#[allow(clippy::similar_names)](with a one-line comment) on the three key-wrapping test modules (key_wrapping_tests,rsa_oaep_tests,pbes2_tests). These flagwrappervswrapped— the natural "wrap an object, get a wrapped result" idiom in crypto tests, wherewrapped.wrapped_keyis then accessed. Renaming to satisfy a one-character-difference heuristic would add churn without improving clarity. Allows are scoped to the specific test modules, not the crate.Verification (all run locally, all green)
cargo clippy --workspace --all-targets --all-features -- -D warningscargo clippy --manifest-path cdx-swift-bridge/Cargo.toml --all-targets -- -D warningscargo build --workspace --all-featurescargo test --workspace --all-featurescargo fmt --all -- --checkThe exact CI clippy command(s) were run locally and pass.