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
Remove Ruby 1.9 code from Lint/ShadowedException
cop
#6527
Conversation
The "non-inline" `rescue nil` was allowed in Ruby 1.9, but disallowed since 2.0: rubocop#3249 (comment) A bit of the code handling `rescue nil` was removed from this cop in 7ef0cf4 (rubocop#4846), but there was still a bit left behind, plus a few specs.
/cc @rrosenblum |
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.
Nice! 💎
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.
The change itself looks fine to me. However, supporting rescue nil
was included in here to prevent possible errors or exceptions in our own code. rescue nil
does not work in newer versions of Ruby, but it results in a TypeError
during execution. Nothing prevents a user from writing rescue nil
. This is the reason that the Lint/RescueType
cop exists. Handling rescue nil
in this cop is an edge case.
Do you mean it’s possible to get a |
No, you won't get a I assume that the tests that were removed will fail with this code change. Handling If a user has |
Ah, gotcha. I just checked, and the cop still works with |
Awesome, that was my main concern. |
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.
Thanks for the discussion and investigation. I fully agree ❤️
The "non-inline"
rescue nil
was allowed in Ruby 1.9, but disallowed since 2.0: #3249 (comment)A bit of the code handling
rescue nil
was removed from this cop in 7ef0cf4 (#4846), but there was still a bit left behind, plus a few specs.Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).and description in grammatically correct, complete sentences.
bundle exec rake default
. It executes all tests and RuboCop for itself, and generates the documentation.