-
-
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
RescueWithoutErrorClass gives false positive #4740
Comments
Looks like the parsed AST is different when using a |
…ier form `rescue` The cop would miss cases of `rescue` without error class when used in modifier form. This change fixes that.
I don't think rescue as a modifier works the way @perlun thinks it works. irb(main):018:0> 3 / 0 rescue NameError
=> NameError I don't know of a syntax that allows the modifier form of rescue to be restricted to a particular class. If there isn't one, then it might make sense to simply not have rubocop complain about the error class when using the modifier form. |
You're right @ctm. This cop should just ignore modifier form |
@ctm Hehe, very good point! 😆 Thanks for pointing that out. I need to fix my code... |
After upgrading to RuboCop 0.50, we are seeing
RescueWithoutErrorClass
being raised for code that does actually provide an error class:Expected behavior
Rubocop should accept this code, since it provides an error class (
NameError
).Actual behavior
Rubocop produced a
Lint/RescueWithoutErrorClass
warning.Steps to reproduce the problem
Probably the following will do, if not, the exact example above:
RuboCop version
Include the output of
rubocop -V
. Here's an example:(don't have
rubocop -V
output since this was running on Travis.)The text was updated successfully, but these errors were encountered: