Skip to content
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

Naming/RescuedExceptionsVariableName does not handle multiple rescues #6902

Closed
anthony-robin opened this issue Apr 8, 2019 · 1 comment · Fixed by #6949
Closed

Naming/RescuedExceptionsVariableName does not handle multiple rescues #6902

anthony-robin opened this issue Apr 8, 2019 · 1 comment · Fixed by #6949
Labels

Comments

@anthony-robin
Copy link
Contributor

Just after upgrading to Rubocop v0.67.2, I discovered that if we have more that one rescue, only the first will be flagged with an offense.

Expected behavior

I should get an offense from Rubocop for any individual rescue that does not follow the defined configuration.

Actual behavior

Only the first rescue is being flagged.

Steps to reproduce the problem

class MyController < ApplicationController
  def create
    # some code here
  rescue MyException => exception # <= flagged
    render_my_exception(exception)
  rescue MyAnotherException => exception # <= not flagged
    render_an_another_exception(exception)
  end
end

RuboCop version

$ [bundle exec] rubocop -V
0.67.2 (using Parser 2.6.2.1, running on ruby 2.6.1 x86_64-darwin18)
@bbatsov bbatsov added the bug label Apr 8, 2019
@AlexWayfer
Copy link
Contributor

Another example:

# frozen_string_literal: true

def foo
  puts 'foo'
rescue ArgumentError => e
  raise unless e.message
end

def bar
  puts 'bar'
rescue ArgumentError => exception
  raise unless exception.message
end

(there are no offenses)

tatsuyafw added a commit to tatsuyafw/rubocop that referenced this issue Apr 20, 2019
…e rescues

As issued in rubocop#6902, the `Naming/RescuedExceptionsVariableName` cop did not
handle multiple rescues as below.

```
begin
  # something
rescue FooException => foo # <= flagged
rescue BarException => bar # <= not flagged
end
```

This changes fix that and enable the cop handle multiple rescues.
bbatsov pushed a commit that referenced this issue Apr 20, 2019
As issued in #6902, the `Naming/RescuedExceptionsVariableName` cop did not
handle multiple rescues as below.

```
begin
  # something
rescue FooException => foo # <= flagged
rescue BarException => bar # <= not flagged
end
```

This changes fix that and enable the cop handle multiple rescues.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants