Sha256: e70563d46dc35a8c98cb5ef312e714d29f4c67a8049d0568e15d43e6c6076891
Contents?: true
Size: 1.16 KB
Versions: 4
Compression:
Stored size: 1.16 KB
Contents
# encoding: utf-8 module Rubocop module Cop module Style # Checks for space between a method name and a left parenthesis in defs. # # @example # # # bad # def func (x) ... end # # # good # def func(x) ... end class SpaceAfterMethodName < Cop include CheckMethods MSG = 'Never put a space between a method name and the opening ' \ 'parenthesis.' def check(_node, _method_name, args, body) 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/ add_offense(pos_before_left_paren, pos_before_left_paren) end end def autocorrect(pos_before_left_paren) @corrections << lambda do |corrector| corrector.remove(pos_before_left_paren) end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems