Sha256: dea6a48d3cdc9ca3e124ef01737b1a87c4cab538bedbe583dd95ffe9a14b004e
Contents?: true
Size: 781 Bytes
Versions: 4
Compression:
Stored size: 781 Bytes
Contents
# encoding: utf-8 module Rubocop module Cop class SymbolArray < Cop MSG = 'Use %i or %I for array of symbols.' def inspect(source, tokens, ast, comments) # %i and %I were introduced in Ruby 2.0 unless RUBY_VERSION < '2.0.0' on_node(:array, ast) do |s| next unless s.loc.begin && s.loc.begin.source == '[' array_elems = s.children # no need to check empty arrays next unless array_elems && array_elems.size > 1 symbol_array = array_elems.all? { |e| e.type == :sym } if symbol_array add_offence(:convention, s.loc.line, MSG) end end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.8.3 | lib/rubocop/cop/symbol_array.rb |
rubocop-0.8.2 | lib/rubocop/cop/symbol_array.rb |
rubocop-0.8.1 | lib/rubocop/cop/symbol_array.rb |
rubocop-0.8.0 | lib/rubocop/cop/symbol_array.rb |