Class: RuboCop::Cop::Minitest::RefuteFalse
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Minitest::RefuteFalse
- Extended by:
- AutoCorrector
- Includes:
- ArgumentRangeHelper
- Defined in:
- lib/rubocop/cop/minitest/refute_false.rb
Overview
Enforces the use of ‘refute(object)` over `assert_equal(false, object)`.
Constant Summary collapse
- MSG_FOR_ASSERT_EQUAL =
'Prefer using `refute(%<arguments>s)`.'
- MSG_FOR_ASSERT =
'Prefer using `refute(%<arguments>s)`.'
- RESTRICT_ON_SEND =
%i[assert_equal assert].freeze
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/rubocop/cop/minitest/refute_false.rb', line 46 def on_send(node) actual, rest_receiver_arg = assert_equal_with_false(node) || assert_with_bang_argument(node) return unless actual = rest_receiver_arg.first arguments = [actual.source, &.source].compact.join(', ') = node.method?(:assert_equal) ? MSG_FOR_ASSERT_EQUAL : MSG_FOR_ASSERT add_offense(node, message: format(, arguments: arguments)) do |corrector| autocorrect(corrector, node, actual) end end |