Sha256: 254fe87401d45c27c3d1896c8cb2d3f326d44ec591a0f8aae5a557f8a872e2a4
Contents?: true
Size: 834 Bytes
Versions: 15
Compression:
Stored size: 834 Bytes
Contents
# encoding: utf-8 module Rubocop module Cop class HashSyntax < Cop ERROR_MESSAGE = 'Ruby 1.8 hash syntax detected' def inspect(file, source, tokens, sexp) each(:assoclist_from_args, sexp) do |assoclist_from_args| keys = assoclist_from_args[1].map { |assoc_new| assoc_new[1][0] } # If at least one of the keys in the hash is neither a symbol (:a) # nor a label (a:), we can't require the new syntax. return if keys.find do |key| not [:symbol_literal, :@label].include?(key) end end each(:assoc_new, sexp) do |assoc_new| if assoc_new[1][0] == :symbol_literal add_offence(:convention, assoc_new[1][1][1][-1].lineno, ERROR_MESSAGE) end end end end end end
Version data entries
15 entries across 15 versions & 1 rubygems