Skip to content

chore: pass clippy --all-targets and enforce it in CI#119

Merged
gvonnessi merged 1 commit into
mainfrom
chore/clippy-all-targets
Jun 17, 2026
Merged

chore: pass clippy --all-targets and enforce it in CI#119
gvonnessi merged 1 commit into
mainfrom
chore/clippy-all-targets

Conversation

@gvonnessi

Copy link
Copy Markdown
Collaborator

Summary

The strict clippy gate cargo clippy --workspace --all-targets --all-features -- -D warnings previously 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-targets gate is enforced from now on. No runtime behavior changes.

⚠️ CI gate tightened (please note)

The clippy invocations are changed from --all-features to --all-targets --all-features, so test/bench/example targets are now linted. Affected steps:

File Step Before → After
.github/workflows/ci.yml Clippy (workspace) --all-features--all-targets --all-features
.github/workflows/ci.yml Clippy Swift bridge (bare) → --all-targets
.github/workflows/publish.yml Clippy (workspace) --all-features--all-targets --all-features

Future 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-targets gate emitted exactly 33 lints. (The original estimate of ~41 included needless_pass_by_value; that pedantic lint does not fire under 1.96.0, confirmed by a cold re-lint at exit 0.)

Lint Count Disposition
default_trait_access 13 Fixed
similar_names 18 Scoped #[allow] (justified)
module_inception 1 Fixed (structural)
manual_contains 1 Fixed

15 fixed via real code changes · 18 scoped-allowed with reasons · 0 crate-level blanket allows.

Fixed (real, idiomatic changes)

  • default_trait_access ×13cdx-core/src/archive/reader.rs (tests): replaced Default::default() with the concrete zip::write::FileOptions::default() in start_file::<&str, ()>(..) calls. The turbofish already pins the type, so this is a no-op at runtime.
  • manual_contains ×1cdx-core/tests/conformance.rs: declared.iter().any(|n| *n == "unknown")declared.contains(&"unknown").
  • module_inception ×1cdx-core/src/document/tests.rs: removed the redundant inner mod tests { .. } wrapper. The file is loaded by #[cfg(test)] mod tests; in document/mod.rs, so it is the tests module; the inner mod tests was pointless nesting. This is a pure dedent — the file's non-whitespace bytes are byte-identical before and after (verified with cmp), so no #[allow] was needed and nothing semantic changed.

Scoped-allowed (with justification)

  • similar_names ×18cdx-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 flag wrapper vs wrapped — the natural "wrap an object, get a wrapped result" idiom in crypto tests, where wrapped.wrapped_key is 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)

Check Result
cargo clippy --workspace --all-targets --all-features -- -D warnings ✅ exit 0 (incl. cold re-lint)
cargo clippy --manifest-path cdx-swift-bridge/Cargo.toml --all-targets -- -D warnings ✅ exit 0
cargo build --workspace --all-features
cargo test --workspace --all-features 1082 passed, 0 failed (matches baseline)
cargo fmt --all -- --check ✅ clean
swift-bridge build + test ✅ 18 passed

The exact CI clippy command(s) were run locally and pass.

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

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@gvonnessi gvonnessi merged commit 0d0bac9 into main Jun 17, 2026
15 of 16 checks passed
@gvonnessi gvonnessi deleted the chore/clippy-all-targets branch June 17, 2026 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant