Sha256: 9a9f1227ea8b1682accd94ea21a9ff1ead4b6b38153ce41e1c9e2bec1463e295
Contents?: true
Size: 752 Bytes
Versions: 1
Compression:
Stored size: 752 Bytes
Contents
# encoding: utf-8 module Rubocop module Cop class SymbolArray < Cop ERROR_MESSAGE = 'Use %i or %I for array of symbols.' def inspect(file, source, tokens, sexp) # %i and %I were introduced in Ruby 2.0 unless RUBY_VERSION < '2.0.0' each(:array, sexp) do |s| array_elems = s[1] # no need to check empty arrays next unless array_elems && array_elems.size > 1 symbol_array = array_elems.all? { |e| e[0] == :symbol_literal } if symbol_array add_offence(:convention, all_positions(s).first.lineno, ERROR_MESSAGE) end end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.7.2 | lib/rubocop/cop/symbol_array.rb |