Sha256: ee5ff3fbfcdd18c5e616b62c76c6f21804697d91b76f5ac612a35990b55db33f

Contents?: true

Size: 1010 Bytes

Versions: 4

Compression:

Stored size: 1010 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    module Style
      # Checks for space between a method name and a left parenthesis.
      class SpaceAfterMethodName < Cop
        MSG = 'Never put a space between a method name and the opening ' +
          'parenthesis.'

        def on_def(node)
          _method_name, args, _body = *node
          check(args)
        end

        def on_defs(node)
          _scope, _method_name, args, _body = *node
          check(args)
        end

        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(nil, pos_before_left_paren)
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-0.14.1 lib/rubocop/cop/style/space_after_method_name.rb
rubocop-0.14.0 lib/rubocop/cop/style/space_after_method_name.rb
rubocop-0.13.1 lib/rubocop/cop/style/space_after_method_name.rb
rubocop-0.13.0 lib/rubocop/cop/style/space_after_method_name.rb