Class: Rubocop::Cop::Style::DefWithoutParentheses
- Defined in:
- lib/rubocop/cop/style/def_parentheses.rb
Overview
This cop checks for missing parentheses in the definition of a method, that takes arguments. Both instance and class/singleton methods are checked.
Constant Summary collapse
- MSG =
'Use def with parentheses when there are arguments.'
Instance Attribute Summary
Attributes inherited from Cop
#autocorrect, #corrections, #debug, #disabled_lines, #offences
Instance Method Summary collapse
Methods inherited from Cop
#add_offence, all, #autocorrect_action, cop_name, cop_type, #do_autocorrect, #ignore_node, inherited, #initialize, lint?, #name, rails?, style?
Constructor Details
This class inherits a constructor from Rubocop::Cop::Cop
Instance Method Details
#on_def(node) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/rubocop/cop/style/def_parentheses.rb', line 44 def on_def(node) _, args = *node if args.children.size > 0 && args.loc.begin.nil? add_offence(:convention, args.loc.expression, MSG) end end |
#on_defs(node) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/rubocop/cop/style/def_parentheses.rb', line 52 def on_defs(node) _, _, args = *node if args.children.size > 0 && args.loc.begin.nil? add_offence(:convention, args.loc.expression, MSG) end end |