Class: RuboCop::Cop::Minitest::VariableAsActualArgument
- Inherits:
-
LiteralAsActualArgument
- Object
- LiteralAsActualArgument
- RuboCop::Cop::Minitest::VariableAsActualArgument
- Defined in:
- lib/rubocop/cop/minitest/variable_as_actual_argument.rb
Overview
Checks for ‘assert_equal` method calls where the first argument is a actual variable, and the second argument is an expected literal.
Constant Summary collapse
- MSG =
'Replace the literal with the second argument.'
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.autocorrect_incompatible_with ⇒ Object
17 18 19 |
# File 'lib/rubocop/cop/minitest/variable_as_actual_argument.rb', line 17 def self.autocorrect_incompatible_with [LiteralAsActualArgument] end |
Instance Method Details
#on_send(node) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rubocop/cop/minitest/variable_as_actual_argument.rb', line 20 def on_send(node) return unless node.method?(:assert_equal) actual, expected, = *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 |