BOHICA-LABS / BOHICA-LABS/prism
Clippy never lints test targets, so lint errors in tests accumulate unseen
- Dominant language
- Rust
- Stars
- 1
- Forks
- 0
- Avg merge
- 4h 46m
- Merged PRs (30d)
- 37
Description
Lint errors in test code accumulate in this repo without anyone seeing them, because clippy never looks at test targets. The gap is one flag wide, but it has been silently collecting debt, and it hides real problems in exactly the code that is supposed to be catching problems.
I hit it filing #288: two brand new test files went in with clippy errors, and every CI check passed.
**Expected.** `Cargo.toml:81-82` denies `unwrap_used` and `expect_used` workspace-wide, and 224 of the 391 files under `crates/*/tests/` open with `#![allow(clippy::unwrap_used, clippy::expect_used)]` to work within that. That convention only makes sense if something enforces the deny in test code. CLAUDE.md also lists `just clippy` as "workspace clippy with -D warnings", implying test code is covered.
**Actual.** Nothing enforces it. Adding `--all-targets` surfaces errors on develop immediately.
## Repro
develop at 561d8bac, one crate
The CI invocation is clean:
```
$ cargo clippy -p prism-dtu-common --all-features -- -D warnings
Finished
```
The same crate with test targets included is not:
```
$ cargo clippy -p prism-dtu-common --all-features --all-targets -- -D warnings
error: function `test_BC_2_06_019_timeline_types_non_exhaustive_and_structure` should have a snake case name
--> crates/prism-dtu-common/src/scenario/mod.rs:486:8
...
error: this assertion is always `true`
--> crates/prism-dtu-common/tests/bc_3_4_001_003_archetype_genopts.rs:547:5
|
547 | assert!(true, "fixture-gen feature gate is active");
```
`assert!(true, ...)` is the kind of thing worth catching: a test line that asserts nothing at all.
I could not measure the workspace-wide count, because `cargo clippy --workspace --all-targets` aborts on the `prism-ocsf` build script before linting anything when `protoc` is absent. That is filed separately as the sibling issue.
## Mechanism
`cargo clippy` without `--all-targets` checks only the default targets, so integration tests under `tests/`, benches, and examples are never linted. Inline `#[cfg(test)] mod tests` blocks are skipped too, since `cfg(test)` is only enabled when building a test target. That is most of the test code in the workspace.
The Justfile recipes have the same shape as CI, so `just check` does not catch it locally either.
Relevant paths: `.github/workflows/ci.yml:76`, `Justfile:29` (`check`), `Justfile:57` (`check-fast`), `Justfile:73` (`check-ci`), `Cargo.toml:81-82`.
Noticed while reading, not part of this issue: `just clippy` at `Justfile:118` is a stub that echoes `TODO: S-0.02 target clippy`, though CLAUDE.md documents it as running workspace clippy.
## Ask
Could the clippy invocations take `--all-targets`, so the workspace deny actually binds in test code? Happy to follow up with a PR carrying the flag plus whatever fallout it surfaces.
Contributor guide
No contributing guide indexed for this repository
Research direction
The issue is about adding `--all-targets` to clippy invocations to lint test code. Check the CI file (.github/workflows/ci.yml:76) and the Justfile recipes (lines 29, 57, 73) to see where clippy is called. Also review Cargo.toml lines 81-82 for the deny rules. Run `cargo clippy --all-targets` on a crate like prism-dtu-common to see the errors it surfaces. The fix is to update the invocations and then address any new lint errors that appear.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- testing, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 75/100