Skip to content

Match recorded violations in strict packs - #43

Open
iMacTia wants to merge 1 commit into
rubyatscale:mainfrom
iMacTia:strict-mode-respects-package-todo
Open

Match recorded violations in strict packs#43
iMacTia wants to merge 1 commit into
rubyatscale:mainfrom
iMacTia:strict-mode-respects-package-todo

Conversation

@iMacTia

@iMacTia iMacTia commented Aug 3, 2026

Copy link
Copy Markdown

Fixes #41.

ViolationIdentifier carries strict, but violations rebuilt from package_todo.yml always get strict: false, so in a strict pack a found violation could never equal its recorded entry. Comparisons now go through recorded_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_violations now also skips recorded violations, matching packwerk's unlisted_strict_mode_violations (Shopify/packwerk#368) and what #166 described as out of scope at the time. --ignore-recorded-violations still surfaces them.

Tests

test_check_with_strict_mode was 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-violations still reports recorded ones. The CSV test moved to contains_strict_violations, which has no todo file, so it still has output to assert against.

cargo test, cargo clippy --all-targets --all-features -- -Dwarnings and cargo fmt --all -- --check all 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.

`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.
@iMacTia
iMacTia requested a review from a team as a code owner August 3, 2026 07:59
@github-project-automation github-project-automation Bot moved this to Triage in Modularity Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

Recorded violations never match in strict packs, so package_todo.yml has no effect

1 participant