Skip to content

Commit

Permalink
Mark autocorrection for Lint/EmptyConditionalBody as unsafe.
Browse files Browse the repository at this point in the history
  • Loading branch information
dvandersluis authored and bbatsov committed Aug 4, 2022
1 parent 0658f99 commit b976534
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
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

0 comments on commit b976534

Please sign in to comment.