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

Add ReceiveNever cop #628

Merged
merged 1 commit into from
Jun 15, 2018
Merged

Add ReceiveNever cop #628

merged 1 commit into from
Jun 15, 2018

Conversation

Darhazer
Copy link
Member

@Darhazer Darhazer commented Jun 8, 2018

Fixes #607


Before submitting the PR make sure the following are checked:

  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Added an entry to the changelog if the new code introduces user-observable changes.
  • The build (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:

  • Added the new cop to config/default.yml.
  • The cop documents examples of good and bad code.
  • The tests assert both that bad code is reported and that good code is not reported.

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
Copy link
Collaborator

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?

Copy link
Member Author

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)
Copy link
Collaborator

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

@bbatsov
Copy link
Contributor

bbatsov commented Jun 12, 2018

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)
Copy link
Contributor

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.

Copy link
Member Author

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 :/

@bquorning
Copy link
Collaborator

@bbatsov Good points both, but not specific to this PR. Would you mind opening two new issues where we can discuss them?

RUBY
end

it 'allows method callsed never' do
Copy link
Collaborator

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
Copy link
Collaborator

@bquorning bquorning Jun 15, 2018

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.

@Darhazer
Copy link
Member Author

Updated

@bquorning bquorning merged commit be949cc into master Jun 15, 2018
@bquorning bquorning deleted the receive-never-cop branch June 15, 2018 16:41
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.

None yet

3 participants