Parent

Files

Class/Module Index [+]

Quicksearch

RuboCop::Cop::Style::MethodCallParentheses

This cop checks for unwanted parentheses in parameterless method calls.

Constants

MSG

Public Instance Methods

autocorrect(node) click to toggle source
# File lib/rubocop/cop/style/method_call_parentheses.rb, line 18
def autocorrect(node)
  # Bail out if the call is going to be auto-corrected by EmptyLiteral.
  if config.for_cop('Style/EmptyLiteral')['Enabled'] &&
      [EmptyLiteral::HASH_NODE,
       EmptyLiteral::ARRAY_NODE,
       EmptyLiteral::STR_NODE].include?(node)
    return
  end
  @corrections << lambda do |corrector|
    corrector.remove(node.loc.begin)
    corrector.remove(node.loc.end)
  end
end
on_send(node) click to toggle source
# File lib/rubocop/cop/style/method_call_parentheses.rb, line 9
def on_send(node)
  _receiver, method_name, *args = *node

  # methods starting with a capital letter should be skipped
  return if method_name =~ /\A[A-Z]/

  add_offense(node, :begin) if args.empty? && node.loc.begin
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.