Sha256: b552d18e2328d54871281b3e59a47198212a43fadde00342735034ffbe690319
Contents?: true
Size: 772 Bytes
Versions: 4
Compression:
Stored size: 772 Bytes
Contents
# encoding: utf-8 module Rubocop module Cop class HashSyntax < Cop MSG = 'Ruby 1.8 hash syntax detected' def on_hash(node) pairs = *node sym_indices = pairs.all? { |p| word_symbol_pair?(p) } if sym_indices pairs.each do |pair| if pair.loc.operator && pair.loc.operator.source == '=>' add_offence(:convention, pair.loc.line, MSG) end end end super end private def word_symbol_pair?(pair) key, _value = *pair if key.type == :sym sym_name = key.to_a[0] sym_name =~ /\A\w+\z/ else false end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.8.3 | lib/rubocop/cop/hash_syntax.rb |
rubocop-0.8.2 | lib/rubocop/cop/hash_syntax.rb |
rubocop-0.8.1 | lib/rubocop/cop/hash_syntax.rb |
rubocop-0.8.0 | lib/rubocop/cop/hash_syntax.rb |