-
-
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
Add ScatteredSetup cop #254
Conversation
b24343d
to
2e9e933
Compare
@andyw8 or @bquorning what do you think of this cop? If you agree with its intent can you review the code and merge if you approve? |
I like it! How about checking eventual arguments? Calling |
Good catch that is definitely necessary |
As I recall, valid arguments are And as you suggested in #252 (comment), adding these to the language definition sounds really useful. |
Nice idea. Just ran it over a large codebase with some very long tests and it seemed to be accurate. This currently generates warnings though:
As @bquorning says, I think we should allow |
704c4ea
to
76b10a4
Compare
76b10a4
to
5e097b0
Compare
4caebed
to
2e30fc3
Compare
I've cleaned up this PR and addressed the functional behavior feedback here. I haven't extracted the different hook scope names to the language yet because I didn't want to further expand this PR. @bquorning @andyw8 lmk what you think |
when :context, :all then :context | ||
when :suite then :suite | ||
else | ||
raise "Unrecognized scope #{scope_argument.to_a.first}" |
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.
Worth defining a rubocop-rspec error for this rather than a plain RuntimeError
?
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.
Updated
LGTM |
2e30fc3
to
1456742
Compare
@andyw8 updated to extract that error class. |
93d1413
to
e6b3a61
Compare
Side note / question @andyw8 @bquorning. I've got these node wrapper that I've also refactored a bit in this PR and I'm struggling to name it well. Right now I've got Anyways, what is a good name for |
e6b3a61
to
bf22733
Compare
Actually I removed the error. It is a slim chance anyone runs into it but if they do it shouldn't raise an error because they are doing something weird |
bf22733
to
5fd33f7
Compare
2148ffd
to
624402b
Compare
e0434dd
to
5c1fa48
Compare
5c46b8f
to
f0921cc
Compare
Add ScatteredSetup cop
You should only use max one hook type per example group.