Skip to content

Commit

Permalink
Mark Minitest/AssertTruthy as unsafe
Browse files Browse the repository at this point in the history
This PR marks `Minitest/AssertTruthy` as unsafe.
As with rubocop#233, this is a false positive issue than autocorrection compatibility.
  • Loading branch information
koic committed Jan 21, 2023
1 parent d0ce98e commit 702d2c3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog/change_mark_minitest_assert_truthy_as_unsafe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#234](https://github.com/rubocop/rubocop-minitest/pull/234): Mark `Minitest/AssertTruthy` as unsafe. ([@koic][])
4 changes: 2 additions & 2 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ Minitest/AssertTruthy:
Description: 'This cop enforces the test to use `assert(actual)` instead of using `assert_equal(true, actual)`.'
StyleGuide: 'https://minitest.rubystyle.guide#assert-truthy'
Enabled: true
SafeAutoCorrect: false
Safe: false
VersionAdded: '0.2'
VersionChanged: '0.26'
VersionChanged: '<<next>>'

Minitest/AssertWithExpectedArgument:
Description: 'This cop tries to detect when a user accidentally used `assert` when they meant to use `assert_equal`.'
Expand Down
9 changes: 8 additions & 1 deletion lib/rubocop/cop/minitest/assert_truthy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ module Minitest
# Enforces the test to use `assert(actual)` instead of using `assert_equal(true, actual)`.
#
# @safety
# This cop's autocorrection is unsafe because true might be expected instead of truthy.
# This cop is unsafe because true might be expected instead of truthy.
# False positives cannot be prevented when this is a variable or method return value.
#
# [source,ruby]
# ----
# assert_equal(true, 'truthy') # failure
# assert('truthy') # success
# ----
#
# @example
# # bad
Expand Down

0 comments on commit 702d2c3

Please sign in to comment.