Sha256: 942b4613fdfd5ee6eb56f1bca6354ae9e96293c70c5cd16e72e6bb64e26d1212
Contents?: true
Size: 1.04 KB
Versions: 2
Compression:
Stored size: 1.04 KB
Contents
# frozen_string_literal: true module RuboCop module Cop module Layout # 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 OnMethodDef MSG = 'Do not put a space between a method name and the opening ' \ 'parenthesis.'.freeze def on_method_def(_node, _method_name, args, _body) return unless args.loc.begin && args.loc.begin.is?('(') expr = args.source_range pos_before_left_paren = range_between(expr.begin_pos - 1, expr.begin_pos) return unless pos_before_left_paren.source =~ /\s/ add_offense(pos_before_left_paren, pos_before_left_paren) end def autocorrect(pos_before_left_paren) ->(corrector) { corrector.remove(pos_before_left_paren) } end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.49.1 | lib/rubocop/cop/layout/space_after_method_name.rb |
rubocop-0.49.0 | lib/rubocop/cop/layout/space_after_method_name.rb |