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



65
66
67
68
69
70
71
72
73
74
75
# File 'lib/rubocop/cop/lint/float_comparison.rb', line 65

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