Skip to content

Commit

Permalink
Mark Minitest/RefuteFalse as unsafe autocorrection
Browse files Browse the repository at this point in the history
Follow up #209 (comment)

This PR marks `Minitest/RefuteFalse` as unsafe autocorrection.
  • Loading branch information
koic committed Jan 21, 2023
1 parent d0ce98e commit 46f03a4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#233](https://github.com/rubocop/rubocop-minitest/issues/233): Mark `Minitest/RefuteFalse` as unsafe autocorrection. ([@koic][])
2 changes: 2 additions & 0 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,9 @@ Minitest/RefuteFalse:
Description: 'Check if your test uses `refute(actual)` instead of `assert_equal(false, actual)`.'
StyleGuide: 'https://minitest.rubystyle.guide#refute-false'
Enabled: true
SafeAutoCorrect: false
VersionAdded: '0.3'
VersionChanged: '<<next>>'

Minitest/RefuteInDelta:
Description: 'This cop enforces the test to use `refute_in_delta` instead of using `refute_equal` to compare floats.'
Expand Down
9 changes: 9 additions & 0 deletions lib/rubocop/cop/minitest/refute_false.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ module Cop
module Minitest
# Enforces the use of `refute(object)` over `assert_equal(false, object)`.
#
# @safety
# This cop's autocorrection is unsafe because it cannot detect failure when second argument is `nil`.
#
# [source,ruby]
# ----
# assert_equal(false, nil) # failure
# refute(nil) # success
# ----
#
# @example
# # bad
# assert_equal(false, actual)
Expand Down

0 comments on commit 46f03a4

Please sign in to comment.