class RuboCop::Cop::Style::OperatorMethodCall

Checks for redundant dot before operator method call. The target operator methods are ‘|`, `^`, `&`, `<=>`, `==`, `===`, `=~`, `>`, `>=`, `<`, `<=`, `<<`, `>>`, `+`, `-`, `*`, `/`, `%`, `**`, `~`, `!`, `!=`, and `!~`.

@example

# bad
foo.+ bar
foo.& bar

# good
foo + bar
foo & bar

Constants

MSG
RESTRICT_ON_SEND

Public Instance Methods

on_send(node) click to toggle source
# File lib/rubocop/cop/style/operator_method_call.rb, line 26
def on_send(node)
  return unless (dot = node.loc.dot)

  _lhs, _op, rhs = *node
  return if rhs.children.first

  add_offense(dot) do |corrector|
    corrector.replace(dot, ' ')
  end
end