Skip to content
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

Merged
merged 11 commits into from
Nov 10, 2022
Merged

Conversation

alanmcruickshank
Copy link
Member

@alanmcruickshank alanmcruickshank commented Nov 8, 2022

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.

@codecov
Copy link

codecov bot commented Nov 8, 2022

Codecov Report

Base: 99.93% // Head: 99.93% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (c73b6aa) compared to base (66fd602).
Patch coverage: 100.00% of modified lines in pull request are covered.

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           
Impacted Files Coverage Δ
src/sqlfluff/core/linter/linter.py 100.00% <ø> (ø)
src/sqlfluff/core/errors.py 100.00% <100.00%> (ø)
src/sqlfluff/core/linter/linted_file.py 96.33% <100.00%> (+0.19%) ⬆️

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.
📢 Do you have feedback about the report comment? Let us know in this issue.

@alanmcruickshank alanmcruickshank marked this pull request as ready for review November 8, 2022 14:55
@@ -406,8 +406,6 @@ def test__linter__empty_file():
(
False,
[
("L006", 3, 16),
("L006", 3, 16),
("L006", 3, 16),
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member Author

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.

Copy link
Member

@pwildenhain pwildenhain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +83 to +92
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👨🏻‍🍳 👌🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deduplicate violations in the same position
3 participants