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

Mark autocorrection for Lint/EmptyConditionalBody as unsafe #10867

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/fix_mark_autocorrection_for.md
@@ -0,0 +1 @@
* [#10867](https://github.com/rubocop/rubocop/pull/10867): Mark autocorrection for `Lint/EmptyConditionalBody` as unsafe. ([@dvandersluis][])
3 changes: 2 additions & 1 deletion config/default.yml
Expand Up @@ -1753,9 +1753,10 @@ Lint/EmptyClass:
Lint/EmptyConditionalBody:
Description: 'Checks for the presence of `if`, `elsif` and `unless` branches without a body.'
Enabled: true
SafeAutoCorrect: false
AllowComments: true
VersionAdded: '0.89'
VersionChanged: '1.33'
VersionChanged: '<<next>>'

Lint/EmptyEnsure:
Description: 'Checks for empty ensure block.'
Expand Down
5 changes: 5 additions & 0 deletions lib/rubocop/cop/lint/empty_conditional_body.rb
Expand Up @@ -7,6 +7,11 @@ module Lint
#
# NOTE: empty `else` branches are handled by `Style/EmptyElse`.
#
# @safety
# Autocorrection for this cop is not safe. The conditions for empty branches that
# the autocorrection removes may have side effects, or the logic in subsequent
# branches may change due to the removal of a previous condition.
#
# @example
# # bad
# if condition
Expand Down