Method: RuboCop::Cop::Lint::FloatComparison#on_send

Defined in:
lib/rubocop/cop/lint/float_comparison.rb

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


48
49
50
51
52
53
54
55
56
57
58
# File 'lib/rubocop/cop/lint/float_comparison.rb', line 48

def on_send(node)
  return unless node.arguments.one?

  lhs = node.receiver
  rhs = node.first_argument

  return if literal_safe?(lhs) || literal_safe?(rhs)

  message = node.method?(:!=) ? MSG_INEQUALITY : MSG_EQUALITY
  add_offense(node, message: message) if float?(lhs) || float?(rhs)
end