-
-
Notifications
You must be signed in to change notification settings - Fork 272
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 ReceiveNever cop #628
Add ReceiveNever cop #628
Conversation
1272f5e
to
ac87c1a
Compare
lambda do |corrector| | ||
corrector.replace(node.parent.loc.selector, 'not_to') | ||
range = range_between( | ||
node.loc.selector.begin_pos - 1, # match the dot 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.
Just a thought: How does this work if the dot is the last character on the preceding line?
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.
Fixed
(send #expectation? :to | ||
{ | ||
$(send (send nil? :receive ...) :never) | ||
$(send (send (send nil? :receive ...) ...) :never) |
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.
Why do we need two patterns here?
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.
Fixed
Btw, what do you think about putting together some RSpec Style Guide as a reference for the RSpec cops? It'd be nice if cops where linked to some document with the rationale behind them. |
|
||
### References | ||
|
||
* [http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ReceiveNever](http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ReceiveNever) |
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 was originally intended to be used for links to blog posts and whatever, complementary to a standard "Style Guide" link.
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 rake tasks intercepts "StyleGuide" from the config, as we have full url there :/
ac87c1a
to
d46358a
Compare
@bbatsov Good points both, but not specific to this PR. Would you mind opening two new issues where we can discuss them? |
d46358a
to
446dd4a
Compare
RUBY | ||
end | ||
|
||
it 'allows method callsed never' 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.
typo: callsed
|
||
MSG = 'Use `not_to receive` instead of `never`.'.freeze | ||
|
||
def_node_matcher :expectation?, Expectations::ALL.send_pattern |
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 matcher seems to not be used.
446dd4a
to
8b7e180
Compare
8b7e180
to
d9bbc0a
Compare
Updated |
Fixes #607
Before submitting the PR make sure the following are checked:
master
(if not - rebase it).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
.