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
Regression of #4198 - Lint/AmbiguousBlockAssociation #7486
Comments
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution and understanding! |
I'm still seeing this issue in RuboCop 0.83.0. |
Still an issue in 0.91.0. |
@luke-hill @mvz apparently it is desired behaviour, because the syntax is ambiguous. You can fix it as suggested here: #8732 (comment) In some cases it might also be possible to write the matches as Or you can disable the cop in this specific case as suggested by bbatsov here: #4198 (comment) |
4198 is impossible here. As I don't have a method on my object output, just the object. The issue is more than not_to is behaving different to to |
This seems to be the same behaviour as mentioned in #4198 (comment). I'm not sure if that was actually ever fixed? As an aside, maybe |
If you're on rubocop 1.13 or later, then you can use |
Can't you just put parantheses around the change method to make it unambiguous?
|
Yep that was offered last year by @kreintjes If someone from the rubocop technical team says this won't be fix then they can close it. I don't think the original method was that bad? |
ah ok, so you're just saying that it's not ambiguous? I was thinking that maybe it was somehow ambiguous in the ruby syntax and that putting parentheses makes it explicitly a method call rather than something else, but I'm not sure what else it would be. It seems like perfectly readable Rspec tbf. |
Our example of this is similar. expect { subject.perform }.to raise_error { |error|
# some expectation of error
# another expectation of error
} This could be fixed as suggested by @jimbali : expect { subject.perform }.to(raise_error { |error|
# some expectation of error
# another expectation of error
}) However, IMO this reduces readability, which I find to be a fantastic feature of rspec. I don't want extra paranthesis above what is there already. We'll be using the |
Expected behavior
expect { move_direction }.not_to change { current_room_id }
should not raise any offensesexpect { move_direction }.to change { current_room_id }.to(new_room_id)
should not raise any offensesActual behavior
expect { move_direction }.not_to change { current_room_id }
raises an offenseexpect { move_direction }.to change { current_room_id }.to(new_room_id)
does not raise an offenseSteps to reproduce the problem
Code is attached above. I added the working variety to show comparison.
RuboCop version
Include the output of
rubocop -V
orbundle exec rubocop -V
if using Bundler. Here's an example:The text was updated successfully, but these errors were encountered: