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

Add autocorrect for Lint/EmptyEnsure cop #4018

Merged
merged 1 commit into from
Feb 6, 2017

Conversation

pocke
Copy link
Collaborator

@pocke pocke commented Feb 5, 2017

$ cat test.rb
begin
  something
ensure
end

$ rubocop -a
Inspecting 1 file
W

Offenses:

test.rb:3:1: W: [Corrected] Empty ensure block detected.
ensure
^^^^^^
test.rb:3:1: C: [Corrected] Extra empty line detected at begin body end.

1 file inspected, 2 offenses detected, 2 offenses corrected

$ cat test.rb
begin
  something
end

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).
  • Used the same coding conventions as the rest of the project.
  • 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.
  • All tests are passing.
  • The new code doesn't generate RuboCop offenses.
  • The PR relates to only one subject with a clear title
    and description in grammatically correct, complete sentences.
  • Updated cop documentation with rake generate_cops_documentation (required only when you've added a new cop or changed the configuration/documentation of an existing cop).

@pocke pocke force-pushed the add-autocorrect-empty-ensure branch from 90e8abf to 8d61671 Compare February 5, 2017 05:54
@bbatsov
Copy link
Collaborator

bbatsov commented Feb 6, 2017

This auto-correct should be disabled by default. Lint cops never have clear-cut auto-correction - e.g. you might have accidentally forgotten the body of an ensure and deleting this is going to cover that up.

@pocke pocke force-pushed the add-autocorrect-empty-ensure branch from 8d61671 to d892208 Compare February 6, 2017 10:01
@pocke
Copy link
Collaborator Author

pocke commented Feb 6, 2017

This auto-correct should be disabled by default. Lint cops never have clear-cut auto-correction - e.g. you might have accidentally forgotten the body of an ensure and deleting this is going to cover that up.

I understand. I've changed the default.

@bbatsov bbatsov merged commit c21fb36 into rubocop:master Feb 6, 2017
@pocke pocke deleted the add-autocorrect-empty-ensure branch February 6, 2017 10:55
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.

2 participants