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.
@example
# bad def foo() # does a thing end # good def foo # does a thing end # also good def foo() does_a_thing end
@example
# bad def Baz.foo() # does a thing end # good def Baz.foo # does a thing end
Constants
- MSG
Public Instance Methods
autocorrect(node)
click to toggle source
# File lib/rubocop/cop/style/def_with_parentheses.rb, line 48 def autocorrect(node) lambda do |corrector| corrector.remove(node.loc.begin) corrector.remove(node.loc.end) end end
on_def(node)
click to toggle source
# File lib/rubocop/cop/style/def_with_parentheses.rb, line 40 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