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, #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, #inspect, lint?, #name, rails?, style?
Constructor Details
This class inherits a constructor from Rubocop::Cop::Cop
Instance Method Details
#on_def(node) ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/rubocop/cop/style/def_parentheses.rb', line 48 def on_def(node) _, args = *node if args.children.size > 0 && args.loc.begin.nil? add_offence(:convention, args.loc.expression, MSG) end super end |
#on_defs(node) ⇒ Object
58 59 60 61 62 63 64 65 66 |
# File 'lib/rubocop/cop/style/def_parentheses.rb', line 58 def on_defs(node) _, _, args = *node if args.children.size > 0 && args.loc.begin.nil? add_offence(:convention, args.loc.expression, MSG) end super end |