Skip to content

Commit

Permalink
Mark unsafe for Lint/RaiseException cop
Browse files Browse the repository at this point in the history
Follow up #8169 (comment).

`Lint/RaiseException` cop is unsafe due to incompatibility
between bad and good cases.

## bad case

```console
% cat /tmp/example_for_exception.rb
begin
  raise Exception
rescue
  puts 'Handle exception'
end

% ruby example_for_exception.rb
example_for_exception.rb:2:in `<main>': Exception (Exception)
```

## good case

```console
% cat example_for_starndard_error.rb
begin
  raise StandardError
rescue
  puts 'Handle exception'
end

% ruby /tmp/example_for_starndard_error.rb
Handle exception
```
  • Loading branch information
koic authored and bbatsov committed Jun 21, 2020
1 parent 5681925 commit 6c40930
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -25,6 +25,7 @@

* [#8146](https://github.com/rubocop-hq/rubocop/pull/8146): Use UTC in RuboCop todo file generation. ([@mauro-oto][])
* [#8149](https://github.com/rubocop-hq/rubocop/pull/8149): Cop `Metrics/CyclomaticComplexity` now counts `&.`, `||=`, `&&=` and blocks known to iterate. Default bumped from 6 to 7. ([@marcandre][])
* [#8178](https://github.com/rubocop-hq/rubocop/pull/8178): Mark unsafe for `Lint/RaiseException`. ([@koic][])

## 0.85.1 (2020-06-07)

Expand Down
1 change: 1 addition & 0 deletions config/default.yml
Expand Up @@ -1620,6 +1620,7 @@ Lint/RaiseException:
Description: Checks for `raise` or `fail` statements which are raising `Exception` class.
StyleGuide: '#raise-exception'
Enabled: pending
Safe: false
VersionAdded: '0.81'
AllowedImplicitNamespaces:
- 'Gem'
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/cops_lint.adoc
Expand Up @@ -2138,7 +2138,7 @@ rather than meant to be part of the resulting symbols.
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged

| Pending
| Yes
| No
| No
| 0.81
| -
Expand Down

0 comments on commit 6c40930

Please sign in to comment.