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
An option for Lint/HandleExceptions to accept comments #7052
Comments
Issue: rubocop#7052 To allow empty rescue blocks with comments
There are two parts to this:
|
Issue: #7052 To allow empty rescue blocks with comments
Follow up rubocop@8a7ee84. This PR fixes the following CI errors. ```console bundle exec rake (snip) 1) RuboCop Project changelog entry after version 0.14.0 has a link to the contributors at the end Failure/Error: expect(entries).to all(match(/\(\[@\S+\]\[\](?:, \[@\S+\]\[\])*\)$/)) expected ["* [rubocop#6649](rubocop#6649): `Layout/AlignHash` supports list of opt...552): `RaiseArgs` allows exception constructor calls with more than one 1 argument. ([@bbatsov][])"] to all match /\(\[@\S+\]\[\](?:, \[@\S+\]\[\])*\)$/ object at index 3 failed to match: expected "* [rubocop#7052](rubocop#7052): Add `AllowComments` option to ` Lint/HandleExceptions`. ([@tejasbubane][]) " to match /\(\[@\S+\]\[\](?:, \[@\S+\]\[\])*\)$/ # ./spec/project_spec.rb:128:in `block (5 levels) in <top (required)>' (snip) 2) RuboCop Project changelog entry body ends with a punctuation Failure/Error: expect(bodies).to all(match(/[\.\!]$/)) expected ["`` supports list of options.", "Add `` config option to ``.", "Add `` to ``.", "Add `` option to ``...nclosed in braces are not noticed.", "Received malformed format string ArgumentError from rubocop."] to all match /[\.\!]$/ object at index 3 failed to match: expected "Add `` option to ``. ([@tejasbubane][]) " to match /[\.\!]$/ # ./spec/project_spec.rb:187:in `block (5 levels) in <top (required)>' ``` https://circleci.com/gh/rubocop-hq/rubocop/55378
I like this, and I think it should be the new default. |
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! |
Fixed in #7297 |
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! |
This issue should be closed, as it was fixed |
## Summary Follow rubocop#7052 (comment). This PR changes `AllowComments` option of `Lint/SuppressedException` to true by default. As is used in RuboCop repo itself, it is a common practice to use source code comments to explain when exception handling is not performed. ## Related Information I think that `Suppressing Exceptions` rule can be refined to a suitable example. https://github.com/rubocop-hq/ruby-style-guide#dont-hide-exceptions
## Summary Follow #7052 (comment). This PR changes `AllowComments` option of `Lint/SuppressedException` to true by default. As is used in RuboCop repo itself, it is a common practice to use source code comments to explain when exception handling is not performed. ## Related Information I think that `Suppressing Exceptions` rule can be refined to a suitable example. https://github.com/rubocop-hq/ruby-style-guide#dont-hide-exceptions
Is your feature request related to a problem? Please describe.
I find that
Lint/HandleExceptions
is often bypassed with anil
in therescue
block. This is not helpful, whereas comments would be. However, arescue
block consisting of only a comment will still trigger aLint/HandleExceptions
offense.Describe the solution you'd like
I would like an option to allow comments within a rescue block to avoid
Lint/HandleExceptions
. PerhapsAllowComments: true
.Describe alternatives you've considered
nil
with no add'l contextAdditional context
n/a
The text was updated successfully, but these errors were encountered: