Rubocop: An option for Lint/HandleExceptions to accept comments

Created on 15 May 2019  路  7Comments  路  Source: rubocop-hq/rubocop

Is your feature request related to a problem? Please describe.

I find that Lint/HandleExceptions is often bypassed with a nil in the rescue block. This is not helpful, whereas comments would be. However, a rescue block consisting of only a comment will still trigger a Lint/HandleExceptions offense.

Describe the solution you'd like

I would like an option to allow comments within a rescue block to avoid Lint/HandleExceptions. Perhaps AllowComments: true.

Describe alternatives you've considered

  • Instead of a config option, allow comments in all cases
  • Disable the cop
  • Also ban rescue blocks consisting of nil with no add'l context
  • Continue with status quo

Additional context

n/a

feature request

Most helpful comment

I like this, and I think it should be the new default.

All 7 comments

There are two parts to this:

  1. Add config option AllowComments - done in #7060
  2. Do not allow rescue blocks consisting of nil (especially single line rescue) - I will do this once above is merged to avoid conflicts.

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

I agree with @rmm5t. I opened PR #7805.

Was this page helpful?
0 / 5 - 0 ratings