diff --git a/changelog/change_mark_minitest_refute_false_as_unsafe_autocorrection.md b/changelog/change_mark_minitest_refute_false_as_unsafe_autocorrection.md new file mode 100644 index 00000000..82e43f9f --- /dev/null +++ b/changelog/change_mark_minitest_refute_false_as_unsafe_autocorrection.md @@ -0,0 +1 @@ +* [#233](https://github.com/rubocop/rubocop-minitest/issues/233): Mark `Minitest/RefuteFalse` as unsafe autocorrection. ([@koic][]) diff --git a/config/default.yml b/config/default.yml index f49a550f..9b2c65f8 100644 --- a/config/default.yml +++ b/config/default.yml @@ -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: '<>' Minitest/RefuteInDelta: Description: 'This cop enforces the test to use `refute_in_delta` instead of using `refute_equal` to compare floats.' diff --git a/lib/rubocop/cop/minitest/refute_false.rb b/lib/rubocop/cop/minitest/refute_false.rb index 60bb19ae..dacdfed4 100644 --- a/lib/rubocop/cop/minitest/refute_false.rb +++ b/lib/rubocop/cop/minitest/refute_false.rb @@ -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)