-
-
Notifications
You must be signed in to change notification settings - Fork 276
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
Complete branch coverage for ContextWording #1972
Conversation
df66d6a
to
4d3e4b2
Compare
4d3e4b2
to
c689dab
Compare
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.
It now feels that the VoidExpect needs a slight rework to be more focused on specs.
I’d love to be able to skip specs for what is not valid RSpec.
c689dab
to
89424c5
Compare
89424c5
to
d3e4268
Compare
@corsonknowles Perhaps this problem can be resolved by the following refactoring: |
Thanks @ydah, it's a little bit philosophical. There is a measurement problem we want to solve, which is just that it's much easier to know when new lines are uncovered with 100% coverage. Since that is my primary concern in this recent set of PRs, I'm happy with both solutions. And then there is another concern for this example, what do we mean when something has a spec? There's an edge case here for when the default patterns have been deliberately removed. What do we want the Cop to do? Currently, it runs and no-ops. The spec in this PR describes that behavior. But maybe we don't want to specify what it does? Maybe we want to allow it to raise? Or have it print a warning? Philosophically, I would suggest it is easier to do that when the behavior is already described. But some might take the position that if we leave it unspecified, it's easier to change. I take the former view, because it's harder to see that an edge case needs handling when it is not described. If we fix it at the code level, but don't add this spec, we still leave this edge case un-described. |
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.
I like this. Describing edge case behavior in specs makes sure that if we change it, it will be an intentional change (where we need to change the spec as well).
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.
No objection to adding this spec.
@@ -214,4 +214,17 @@ | |||
end | |||
end | |||
end | |||
|
|||
context 'when `AllowedPatterns:` and `Prefixes:` are both empty' do |
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.
memo) In this case, it is pointless to enable this cop because it is not always an offense. Should we occur warning or runtime error for this setting? WDYT? @rubocop/rubocop-rspec
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.
it is not always an offense
I don’t understand. Do you mean it’s not deterministic?
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.
The following checks are always considered non-offenses:
return false if allowed_patterns.empty? |
This Cop sets valid wording in Prefixes
and AllowedPatterns
, but it always dose not occur offenses if there is no valid wording setting. I don't think that's the intended setting, but users have no way of knowing right now. Because it's always dose not occur offenses.
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.
Right, with these settings, there will be no offenses, regardless of what is or is not in the Context. It is always not an offense. (I'm not attached to it staying that way).
I looked at the Obsoletion setup recently, and I think it raises runtime errors with the expectation that the user will want to fix those issues. That feels similar to how a user may want to fix the config or disable this cop instead of letting it run "on empty"
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.
It’s an unlikely combination of settings, so unless it’s very simple to implement, I don‘t think we need to warn our users about it.
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.
If the Prefixes
and AllowedPatterns
are empty to begin with, there is no allowed Wording, so it might be better to make them all violations. That way, users would notice the misconfiguration and it would not be too difficult to implement.
…`Prefixes` and `AllowedPatterns` are empty see: #1972 (comment)
…th `Prefixes` and `AllowedPatterns` are empty see: #1972 (comment)
Completes branch coverage for the ContextWording cop.
See related efforts:
Before:
Before submitting the PR make sure the following are checked:
master
(if not - rebase it).CHANGELOG.md
if the new code introduces user-observable changes.bundle exec rake
) passes (be sure to run this locally, since it may produce updated documentation that you will need to commit).If you have created a new cop:
config/default.yml
.Enabled: pending
inconfig/default.yml
.Enabled: true
in.rubocop.yml
.VersionAdded: "<<next>>"
indefault/config.yml
.If you have modified an existing cop's configuration options:
VersionChanged: "<<next>>"
inconfig/default.yml
.