Repository navigation
List each strict violation once in JSON and CSV output - #63
Merged
Merged
Conversation
An unrecorded strict violation is in both `reportable_violations` and `strict_mode_violations`, and the JSON and CSV formatters chained the two sets, so they emitted it twice as identical entries. JSON's `violation_count` counted both. Emit their union instead. Text output is unchanged. It lists the violation in the report and again as a strict-mode message, which matches packwerk: `add_offense` puts every unlisted offense in `new_violations`, and `check` also shows `unlisted_strict_mode_violations`. The CSV test now compares whole lines, since `contains` passed with the duplicate row present. New tests cover JSON on the same fixture and both formats under --ignore-recorded-violations. All four fail on main.
2 of 3 tasks
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.
Summary
pks check -o jsonand-o csvemitted every unrecorded strict violation twice, as byte-identical entries. Oncontains_strict_violations, main prints two identical CSV rows, and the JSON has two identicalviolationswithviolation_count: 2next tostrict_violation_count: 1.The cause is that an unrecorded strict violation is in both
reportable_violationsandstrict_mode_violations, and both formatters built their list withchain!over the two sets. They now take the sets'union, so each violation appears once andviolation_countcounts distinct violations. That also makes the schema's description ofstrict_violation_countas a subset ofviolation_counttrue.Text output and
CheckAllResultare deliberately unchanged. Text lists the violation in the report and again as a strict-mode message, which matches packwerk:OffenseCollection#add_offenseputs every unlisted offense innew_violationswhether or not it's strict, andCheckCommandshows bothoutstanding_offensesandunlisted_strict_mode_violations. Only the two formatters merged the sets into one list.This is one of the two follow-ups from the #43 review. The other is #64, which moves
strictontoViolation. The two branches merge cleanly in either order.Tests
test_check_with_strict_mode_output_csvnow compares whole lines. Withcontains, it passed while the duplicate row was there.contains_strict_violations, plus CSV and JSON onuses_strict_modewith--ignore-recorded-violations, where recorded strict violations are in both sets.violation_count2 instead of 1, four rows instead of 2, andviolation_count4 instead of 2.Test plan
cargo test, 269 passed, plus fmt and clippy.simple_app, the strict fixtures,contains_package_todoandcontains_stale_violations, with and without--ignore-recorded-violations. Text output is identical. JSON and CSV contain the same distinct entries, now with no duplicates.