Method: RuboCop::Cop::Style::InverseMethods#on_send

Defined in:
lib/rubocop/cop/style/inverse_methods.rb

#on_send(node) ⇒ Object Also known as: on_csend



78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/rubocop/cop/style/inverse_methods.rb', line 78

def on_send(node)
  inverse_candidate?(node) do |method_call, lhs, method, rhs|
    return unless inverse_methods.key?(method)
    return if negated?(node) || safe_navigation_incompatible?(method_call)
    return if part_of_ignored_node?(node)
    return if possible_class_hierarchy_check?(lhs, rhs, method)

    add_offense(node, message: message(method, inverse_methods[method])) do |corrector|
      correct_inverse_method(corrector, node)
    end
  end
end