Skip to content

Commit

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

This PR marks `Minitest/RefuteFalse` as unsafe.
  • Loading branch information
koic committed Jan 21, 2023
1 parent d0ce98e commit 442c0ec
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog/change_mark_minitest_refute_false_as_unsafe.md
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. ([@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
Safe: 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
10 changes: 10 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,16 @@ module Cop
module Minitest
# Enforces the use of `refute(object)` over `assert_equal(false, object)`.
#
# @safety
# This cop is unsafe because it cannot detect failure when second argument is `nil`.
# False positives cannot be prevented when this is a variable or method return value.
#
# [source,ruby]
# ----
# assert_equal(false, nil) # failure
# refute(nil) # success
# ----
#
# @example
# # bad
# assert_equal(false, actual)
Expand Down

0 comments on commit 442c0ec

Please sign in to comment.