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
Lint/AmbiguousBlockAssociation Pattern Matching Regression #10969
Comments
@ydah, please look into this. |
@jcalvert You are right, this problem is happening. I had missed it. Thank you. |
As I mentioned in #10970 (comment) , I think this is the same problem with |
|
Agreed. |
|
…ttern` to match on `send_node.source` instead of `method_name`.
[Fix #10969] Allow `Lint/AmbiguousBlockAssociation` `AllowedPa…
I discovered what I believe to be a regression in the behavior of the
Lint/AmbiguousBlockAssociation
cop from v1.33.0 on. For a large code base, when upgrading RuboCop from 1.32 to the latest revision, I saw previously matching lines now fail.When the commit was made deprecating IgnoredMethods for AllowedMethods and AllowedPatterns, the argument to
ignored_method?
was changed fromnode.last_argument.send_node.source
tonode.last_argument.method_name
formatches_allowed_pattern?
. This means that the string passed to the regular expression changed, so regular expressions that worked prior to 1.33.0 may not match. The output of the cop message still usessend_node.source
for interpolation as well. This makes the message instructions difficult to mark for allowance because the output will include the whole method chain but only match on the last call.Given the language of the output message it's possible the intention would be for this cop to only want the last method call in the chain to appear. The most common usage for the Allowed methods and patterns on this cop is for the
rspec
style - because of that I would provide color commentary that I think providing the whole method chain to match against the regular expression is more useful. Idiomatic rspec usage is typically in conjunction with other method calls likereceive
andwith
which help differentiate specs from legitimate uses where we would want the cop to trigger.Expected behavior
for
AllowedPatterns
of[/receive\(.*?\)\.twice/]
expect the string
to have no offenses
Actual behavior
Steps to reproduce the problem
Included above
RuboCop version
The text was updated successfully, but these errors were encountered: