class RuboCop::Cop::Style::DefWithParentheses

This cop checks for parentheses in the definition of a method, that does not take any arguments. Both instance and class/singleton methods are checked.

Constants

MSG

Public Instance Methods

on_def(node) click to toggle source
# File lib/rubocop/cop/style/def_with_parentheses.rb, line 12
def on_def(node)
  return if node.single_line?
  return unless !node.arguments? && node.arguments.loc.begin

  add_offense(node.arguments, location: :begin)
end
Also aliased as: on_defs
on_defs(node)
Alias for: on_def

Private Instance Methods

autocorrect(node) click to toggle source
# File lib/rubocop/cop/style/def_with_parentheses.rb, line 22
def autocorrect(node)
  lambda do |corrector|
    corrector.remove(node.loc.begin)
    corrector.remove(node.loc.end)
  end
end