Sha256: 1e03e95cc9d3f0f41121a6f4dd8f3008623bac357b53db885f43211ef39c3e4e

Contents?: true

Size: 578 Bytes

Versions: 5

Compression:

Stored size: 578 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    module Style
      # This cop checks for array literals made up of symbols
      # that are not using the %i() syntax.
      #
      # This check makes sense only on Ruby 2.0+.
      class SymbolArray < Cop
        include ArraySyntax

        MSG = 'Use %i or %I for array of symbols.'

        def on_array(node)
          # %i and %I were introduced in Ruby 2.0
          unless RUBY_VERSION < '2.0.0'
            add_offense(node, :expression) if array_of?(:sym, node)
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rubocop-0.21.0 lib/rubocop/cop/style/symbol_array.rb
rubocop-0.20.1 lib/rubocop/cop/style/symbol_array.rb
rubocop-0.20.0 lib/rubocop/cop/style/symbol_array.rb
rubocop-0.19.1 lib/rubocop/cop/style/symbol_array.rb
rubocop-0.19.0 lib/rubocop/cop/style/symbol_array.rb