Sha256: cfefc2d6ad8214567456bea8d97e05849f31cecc3eb41bbe13052469e9c2fca2

Contents?: true

Size: 563 Bytes

Versions: 1

Compression:

Stored size: 563 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    class ArrayLiteral < Cop
      ERROR_MESSAGE = 'Use array literal [] instead of Array.new.'

      def inspect(file, source, tokens, sexp)
        each(:method_add_arg, sexp) do |s|
          potential_class = s[1][1][1]

          if potential_class[1] == 'Array' && s[1][3][1] == 'new' &&
              s[2] == [:arg_paren, nil]
            add_offence(:convention,
                        potential_class[2].lineno,
                        ERROR_MESSAGE)
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubocop-0.6.0 lib/rubocop/cop/array_literal.rb