Feat/test quality execution#33
Merged
Merged
Conversation
…aren't flagged (v1.4.2) SIT (single-impl trait) counted only production impls — the structural metadata walk skips test code — so a non-pub trait with one production impl plus #[cfg(test)] test-double impls (the idiomatic DI / test-seam pattern) was wrongly flagged as an over-abstraction. It now counts #[cfg(test)] trait impls toward the trait's total implementor count and fires only when that total is 1. A genuine single-impl trait (one prod impl, no doubles) is still flagged. "Test" covers a whole #![cfg(test)] / integration-test file, an inline #[cfg(test)] mod, and an item-level #[cfg(test)] on the impl (collect_item_metadata no longer miscounts the latter as a production impl). Counting is name-based (the metadata models no trait identity), so it is scoped per module: a test impl whose trait is a bare name defined as a test-only trait in the same module is attributed to that local trait, not a same-named production trait — so an unrelated test-only `trait Clock` does not suppress the production `Clock`, while a real double in another test module still counts. Known residual: a test impl of an imported/external trait sharing a production trait's last-segment name still collides (symmetric with the pre-existing production-side name collision; full resolution needs real trait identity). Sibling detector OI is unaffected — it matches impl locations, it does not count (pinned). Regressed when v1.4.x improved #[cfg(test)] mod foo;-chain test-file recognition, which correctly excluded companion test files and shrank SIT's denominator. Four gates green: cargo fmt, 1860 nextest, self-analysis 0 findings, clippy. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… SIT counts impls purely by name SIT now counts #[cfg(test)] trait impls toward a trait's total implementor count (so a test-seam trait — one prod impl plus test doubles — is not flagged), using deliberately name-based counting: it never drops a real double (no false positive on a legitimate seam), accepting a safe, documented false negative on a rare name collision with an unrelated test-only trait. Earlier scope/path heuristics were removed because resolving self::/super::/glob/absolute paths is trait identity, which the name-keyed metadata models on neither side. Making SIT count item-level #[cfg(test)] impls surfaced a broader inconsistency: the other structural detectors treated #[cfg(test)] code in a production file as production. They now honour #[cfg(test)] at every level that can occur in compiling code: - item-level #[cfg(test)] impl: BTC, SLM, NMS, DEH, IET (+ SIT/OI via metadata) - #[cfg(test)] on an impl method: BTC, SLM, NMS, DEH - #[cfg(test)] pub fn: IET, DEH consistent with whole test files and #[cfg(test)] mod blocks. Four gates green: cargo fmt, 1870 nextest, self-analysis 0 findings, clippy.
f943c18 to
91044d5
Compare
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.
No description provided.