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

Support autocorrection for Lint/RaiseException #8169

Merged
merged 1 commit into from Jun 21, 2020

Conversation

koic
Copy link
Member

@koic koic commented Jun 19, 2020

This PR supports autocorrection for Lint/RaiseException.


Before submitting the PR make sure the following are checked:

  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Added an entry to the Changelog if the new code introduces user-observable changes. See changelog entry format.
  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Run bundle exec rake default. It executes all tests and RuboCop for itself, and generates the documentation.

@koic koic force-pushed the support_autocorrect_for_raise_exception branch from d232f40 to eede319 Compare June 20, 2020 01:50
@bbatsov
Copy link
Collaborator

bbatsov commented Jun 20, 2020

I guess we should mark this cop as unsafe.

@koic koic force-pushed the support_autocorrect_for_raise_exception branch 2 times, most recently from 1d50bbc to 35d3afb Compare June 21, 2020 02:34
@koic
Copy link
Member Author

koic commented Jun 21, 2020

Sure. I will open another PR to have it add an entry that marks it unsafe to the changelog.

koic added a commit to koic/rubocop that referenced this pull request Jun 21, 2020
Follow up rubocop#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
```
bbatsov pushed a commit that referenced this pull request Jun 21, 2020
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
```
@koic koic force-pushed the support_autocorrect_for_raise_exception branch 2 times, most recently from 1a73e28 to db93b8e Compare June 21, 2020 06:10
This PR supports autocorrection for `Lint/RaiseException`.
@koic koic force-pushed the support_autocorrect_for_raise_exception branch from db93b8e to d197c84 Compare June 21, 2020 06:20
@koic koic merged commit e013060 into rubocop:master Jun 21, 2020
@koic koic deleted the support_autocorrect_for_raise_exception branch June 21, 2020 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants