Class: Rubocop::Cop::Style::SpaceAfterMethodName
- Defined in:
- lib/rubocop/cop/style/space_after_method_name.rb
Overview
Checks for space between a method name and a left parenthesis.
Constant Summary collapse
- MSG =
'Never put a space between a method name and the opening ' + 'parenthesis.'
Constants inherited from Cop
Instance Attribute Summary
Attributes inherited from Cop
#config, #corrections, #offences, #processed_source
Instance Method Summary collapse
- #autocorrect(pos_before_left_paren) ⇒ Object
- #check(args) ⇒ Object
- #on_def(node) ⇒ Object
- #on_defs(node) ⇒ Object
Methods inherited from Cop
#add_offence, all, #autocorrect?, #convention, #cop_config, cop_name, #cop_name, cop_type, #debug?, #ignore_node, inherited, #initialize, lint?, #message, non_rails, rails?, style?, #support_autocorrect?, #warning
Constructor Details
This class inherits a constructor from Rubocop::Cop::Cop
Instance Method Details
#autocorrect(pos_before_left_paren) ⇒ Object
32 33 34 35 36 |
# File 'lib/rubocop/cop/style/space_after_method_name.rb', line 32 def autocorrect(pos_before_left_paren) @corrections << lambda do |corrector| corrector.remove(pos_before_left_paren) end end |
#check(args) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rubocop/cop/style/space_after_method_name.rb', line 21 def check(args) return unless args.loc.begin && args.loc.begin.is?('(') expr = args.loc.expression pos_before_left_paren = Parser::Source::Range.new(expr.source_buffer, expr.begin_pos - 1, expr.begin_pos) if pos_before_left_paren.source =~ /\s/ convention(pos_before_left_paren, pos_before_left_paren) end end |
#on_def(node) ⇒ Object
11 12 13 14 |
# File 'lib/rubocop/cop/style/space_after_method_name.rb', line 11 def on_def(node) _method_name, args, _body = *node check(args) end |
#on_defs(node) ⇒ Object
16 17 18 19 |
# File 'lib/rubocop/cop/style/space_after_method_name.rb', line 16 def on_defs(node) _scope, _method_name, args, _body = *node check(args) end |