-
Notifications
You must be signed in to change notification settings - Fork 1
[GH-6765] Linter should fail if baseline no longer relevent #20
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
Changes from all commits
a9f9092
32677da
5136676
623fb87
bfc46a8
015abe6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| RSpec::Matchers.define :be_empty_with_exceptions do |custom_message=nil, allowlist: nil, baseline: nil| | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't we also do the same for We could also update the existing matchers to accept an optional allowlist and baseline, instead of having different matchers.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, how would this work with different types of baseline? For example, sometimes we have a baseline of classes, or baseline of files, or baseline of method names, etc.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It works with classes / and filenames because it check against each of the fields... Sorry this should of still been a draft
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we truly have no consumer for the
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why don't we update the existing matchers to add an optional param of baseline? Wouldn't this be more consistent with the existing API? |
||
| include Rubyzen::Matchers::MatcherHelpers | ||
|
|
||
| match do |subject_collection| | ||
| @custom_message = custom_message | ||
| @classified_items = classify_items(subject_collection, allowlist: allowlist, baseline: baseline) | ||
| @offenders = @classified_items[:violations] | ||
| stale_exception_groups = [] | ||
| stale_exception_groups << 'baseline entries' if @classified_items[:stale_baseline].any? | ||
| stale_exception_groups << 'allowlist entries' if @classified_items[:stale_allowlist].any? | ||
|
|
||
| @failure_reason = if @classified_items[:violations].any? && stale_exception_groups.any? | ||
| "Expected to be empty, but found live violations and stale #{stale_exception_groups.join(' and ')}." | ||
| elsif @classified_items[:violations].any? | ||
| 'Expected to be empty, but found live violations.' | ||
| elsif stale_exception_groups.any? | ||
| "Expected to be empty, but found stale #{stale_exception_groups.join(' and ')}." | ||
| end | ||
|
|
||
| @classified_items[:violations].empty? && | ||
| @classified_items[:stale_baseline].empty? && | ||
| @classified_items[:stale_allowlist].empty? | ||
| end | ||
|
|
||
| failure_message do |_| | ||
| message_for_failure(@failure_reason || 'Expected to be empty, but had unmatched elements.') | ||
| end | ||
|
|
||
| failure_message_when_negated do |_| | ||
| message_for_failure('Expected not to be empty, but had no matched elements.') | ||
| end | ||
| end | ||
Uh oh!
There was an error while loading. Please reload this page.
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.
nit: check if classes collection is doing this and has same name