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
[Fix #7826] Add new Layout/SpaceAroundMethodCall
cop
#7857
[Fix #7826] Add new Layout/SpaceAroundMethodCall
cop
#7857
Conversation
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.
Should this support auto-correction? How does this work with safe navigation?
I think this cop should be a bit broader and check for all method invocation operators - @rrosenblum already mentioned safe navigation, but there's also |
# # good | ||
# foo.bar | ||
# foo.bar.buzz | ||
# foo |
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.
You can also have chaining in a suffix form.
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.
Chaining in a suffix form is a bad style. There is already a cop for that so not including it in the example.
I have added a spec for chaining in suffix form though.
module RuboCop | ||
module Cop | ||
module Layout | ||
# Checks dot method calls to not have spaces around them. |
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'd use "method call operator" terminology 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.
Makes sense. Changing it to Checks method call operators to not have spaces around them.
Keeping it plural since it can have method chains also.
@bbatsov I have changed name to |
Okay, ping me when this is ready for a review again. |
b27c302
to
edd7c68
Compare
@bbatsov This is ready for review. |
@saurabhmaurya15 I think you can improve the test suite a bit if you used shared examples there, as the tests for |
edd7c68
to
3806620
Compare
3806620
to
f6c201e
Compare
Thanks! |
Follow rubocop#7384, rubocop#7857, and rubocop#7869. This PR fixes the next release version with 0.82 because RuboCop 0.81 has been released. This version (0.82) is based on rubocop#7851.
This MR adds a cop to for checking dot method calls to not have spaces around them.
It works for multiple method calls in a single line or in multiple lines.
closes #7826
Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).bundle exec rake default
. It executes all tests and RuboCop for itself, and generates the documentation.