Match recorded violations in strict packs - #43
Open
iMacTia wants to merge 1 commit into
Open
Conversation
`ViolationIdentifier` carries `strict`, but violations rebuilt from `package_todo.yml` always get `strict: false`, so a found violation in a strict pack could never equal its recorded entry. That made all three comparisons in `CheckAllBuilder` miss at once: the same recorded violation was reported as new, as a strict-mode violation, and as a stale todo. Comparisons now go through `recorded_key()`, which zeroes the flag, since `strict` describes how a violation is treated rather than which one it is. `build_strict_mode_violations` also skips recorded violations now, matching packwerk's `unlisted_strict_mode_violations` (Shopify/packwerk#368), so turning strict on blocks new violations without requiring every recorded one to be fixed first. `--ignore-recorded-violations` still surfaces them.
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.
Fixes #41.
ViolationIdentifiercarriesstrict, but violations rebuilt frompackage_todo.ymlalways getstrict: false, so in a strict pack a found violation could never equal its recorded entry. Comparisons now go throughrecorded_key(), which zeroes the flag.That alone fixes the two unambiguous symptoms: a recorded violation in a strict pack was reported as new, and its todo entry was reported as stale.
The third change is a policy one, and separable if you'd rather not take it.
build_strict_mode_violationsnow also skips recorded violations, matching packwerk'sunlisted_strict_mode_violations(Shopify/packwerk#368) and what #166 described as out of scope at the time.--ignore-recorded-violationsstill surfaces them.Tests
test_check_with_strict_modewas asserting the old behaviour against a fixture whose todo file already recorded the violation, so it now asserts tolerance and is renamed to say so. Two cases added to pin the parts that keep strict mode useful: an unrecorded strict violation still exits 1, and--ignore-recorded-violationsstill reports recorded ones. The CSV test moved tocontains_strict_violations, which has no todo file, so it still has output to assert against.cargo test,cargo clippy --all-targets --all-features -- -Dwarningsandcargo fmt --all -- --checkall pass.Effect on a real app
15.6k files, 65 packs, two of them strict with 66 recorded todo entries. Stock 0.4.0 on that tree: 185 strict violations and 135 stale todos. With this patch, both go to zero for the strict packs.