Class: RuboCop::Cop::Minitest::LiteralAsActualArgument
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Minitest::LiteralAsActualArgument
- Extended by:
- AutoCorrector
- Includes:
- ArgumentRangeHelper
- Defined in:
- lib/rubocop/cop/minitest/literal_as_actual_argument.rb
Overview
Enforces correct order of expected and actual arguments for ‘assert_equal`.
Constant Summary collapse
- MSG =
'Replace the literal with the first argument.'- RESTRICT_ON_SEND =
i[assert_equal].freeze
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rubocop/cop/minitest/literal_as_actual_argument.rb', line 27 def on_send(node) return unless node.method?(:assert_equal) expected, actual, = *node.arguments return unless actual&.recursive_basic_literal? return if expected.recursive_basic_literal? add_offense(all_arguments_range(node)) do |corrector| autocorrect(corrector, node, expected, actual) end end |