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

Regression: false positive for Lint/SuppressedException in blocks #8081

Closed
timoschilling opened this issue Jun 2, 2020 · 0 comments · Fixed by #8082
Closed

Regression: false positive for Lint/SuppressedException in blocks #8081

timoschilling opened this issue Jun 2, 2020 · 0 comments · Fixed by #8082
Labels

Comments

@timoschilling
Copy link
Contributor

Regresion

0.85.0 introduced a regression in Lint/SuppressedException in blocks, 0.84.0 didn't find any offences in the example below.

Expected behavior

No offense should be detected.

Actual behavior

test.rb:4:1: W: Lint/SuppressedException: Do not suppress exceptions.
rescue Foo
^^^^^^^^^^

Steps to reproduce the problem

  1. Create a file
# frozen_string_literal: true

foo do
rescue Foo
  # ok
end
  1. Run rubocop on this file

RuboCop version

$ [bundle exec] rubocop -V
0.85.0 (using Parser 2.7.1.3, rubocop-ast 0.0.3, running on ruby 2.6.6 x86_64-linux)
@koic koic added the bug label Jun 2, 2020
koic added a commit to koic/rubocop that referenced this issue Jun 4, 2020
Fixes rubocop#8081.

This PR fixes an error for `Lint/SuppressedException`
when empty rescue block in `do` block.

```console
% cat example.rb
foo do
rescue Foo
  # ok
end

% bundle exec rubocop --only Lint/SuppressedException
(snip)

Inspecting 1 file
W

Offenses:

example.rb:2:1: W: Lint/SuppressedException: Do not suppress exceptions.
rescue Foo
^^^^^^^^^^

1 file inspected, 1 offense detected
```

`do` block rescue is a syntax introduced in Ruby 2.5.
@koic koic closed this as completed in #8082 Jun 4, 2020
koic added a commit that referenced this issue Jun 4, 2020
…ssed_exception

[Fix #8081] Fix an error for `Lint/SuppressedException`
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.

2 participants