Skip to content

Commit

Permalink
Mark Style/IfWithBooleanLiteralBranche as unsafe auto-correction
Browse files Browse the repository at this point in the history
Follow #9461 (comment).

This PR marks `Style/IfWithBooleanLiteralBranche` as unsafe auto-correction.
  • Loading branch information
koic authored and bbatsov committed Jan 31, 2021
1 parent 3e26be1 commit 5870d6d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#9476](https://github.com/rubocop-hq/rubocop/pull/9476): Mark `Style/IfWithBooleanLiteralBranche` as unsafe auto-correction. ([@koic][])
1 change: 1 addition & 0 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3521,6 +3521,7 @@ Style/IfWithBooleanLiteralBranches:
Description: 'Checks for redundant `if` with boolean literal branches.'
Enabled: pending
VersionAdded: '1.9'
SafeAutoCorrect: false
AllowedMethods:
- nonzero?

Expand Down
2 changes: 2 additions & 0 deletions lib/rubocop/cop/style/if_with_boolean_literal_branches.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ module Style
# This cop checks for redundant `if` with boolean literal branches.
# It checks only conditions to return boolean value (`true` or `false`) for safe detection.
# The conditions to be checked are comparison methods, predicate methods, and double negative.
# However, auto-correction is unsafe because there is no guarantee that all predicate methods
# will return boolean value. Those methods can be allowed with `AllowedMethods` config.
#
# @example
# # bad
Expand Down

0 comments on commit 5870d6d

Please sign in to comment.