-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Style/MultilineMethodCallIndentation incorrectly autocorrects with nested method calls #3331
Comments
First, a point about what we should expect. Since the style is called indented relative to receiver, we can't expect the method name to be aligned with a receiver. I would suggest that the expected behavior (for you, and that may not be what I expect) is expect(MyClass).to have_received(:a_method).
with(some: param) An extended (contrived) example of what we support today: # aligned
a = expect(MyClass).to have_received(:a_method).
with(some: param)
# indented_relative_to_receiver
a = expect(MyClass).to have_received(:a_method).
with(some: param)
# indented
a = expect(MyClass).to have_received(:a_method).
with(some: param) If we're not happy with this, perhaps we should change the # aligned
a = expect(MyClass).to have_received(:a_method).
with(some: param)
# indented_relative_to_receiver
a = expect(MyClass).to have_received(:a_method).
with(some: param)
# indented
a = expect(MyClass).to have_received(:a_method).
with(some: param) I'm not sure if there are any unwanted implications, going in this direction. |
@jonas054 yeah (for me) your example at the bottom of your comment is what I would expect for I don't think it's necessary to make a breaking change regarding what a = expect(MyClass).to have_received(:a_method).
with(some: param) Couldn't I just do |
I'm just trying to save you some work. I would assume that there are people who would want this style: a = expect(MyClass).to have_received(:a_method).
with(some: param) |
@jonas054 is there something that I can do to help here? I know your time is valuable. |
@jfelchner Sorry this is taking so long. If you can write some failing test cases and submit them as a gist, a PR, a branch, or whatever, I'll do the implementation. |
@jonas054 I'm on it! |
@jonas054 I have the test done but I'm actually reworking the other ones so that they better reflect what I'm looking for. I haven't forgotten about this. 👍 |
The new
indented_relative_to_receiver
doesn't work correctly in all instances. It appears that if there is a method call as a parameter to a method, the cop attempts to align with the receiver of the first method instead of align with the receiver of the second.Expected behavior
Actual behavior
Steps to reproduce the problem
See above
RuboCop version
Include the output of
rubocop -V
:The text was updated successfully, but these errors were encountered: