-
-
Notifications
You must be signed in to change notification settings - Fork 729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deduplicate violations in the source space #4041
Conversation
Codecov ReportBase: 99.93% // Head: 99.93% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #4041 +/- ##
=======================================
Coverage 99.93% 99.93%
=======================================
Files 190 190
Lines 14577 14594 +17
=======================================
+ Hits 14568 14585 +17
Misses 9 9
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
@@ -406,8 +406,6 @@ def test__linter__empty_file(): | |||
( | |||
False, | |||
[ | |||
("L006", 3, 16), | |||
("L006", 3, 16), | |||
("L006", 3, 16), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even after deduplication, it looks like there are still 2 occurrences of:
("L006", 3, 16),
Any idea why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah - yeah I can see this is confusing. The rules we're checking is L006, which checks for whitespace before and after the operator. I've added a comment to explain this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deduplication means that we only get 2 rather than 4.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
new_violations = [] | ||
dedupe_buffer = set() | ||
for v in violations: | ||
signature = v.source_signature() | ||
if signature not in dedupe_buffer: | ||
new_violations.append(v) | ||
dedupe_buffer.add(signature) | ||
else: | ||
linter_logger.debug("Removing duplicate source violation: %s", v) | ||
return new_violations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👨🏻🍳 👌🏻
This resolves #4040.
Duplicate violations (e.g. from multiple passes through a jinja loop) confuse the user and also end up just being deduplicated later. This filters them out early.