Method: RuboCop::Cop::Style::StringHashKeys#on_pair

Defined in:
lib/rubocop/cop/style/string_hash_keys.rb

#on_pair(node) ⇒ Object

[View source]

42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/rubocop/cop/style/string_hash_keys.rb', line 42

def on_pair(node)
  return unless string_hash_key?(node)

  key_content = node.key.str_content
  return unless key_content.valid_encoding?
  return if receive_environments_method?(node)

  add_offense(node.key) do |corrector|
    symbol_content = key_content.to_sym.inspect

    corrector.replace(node.key, symbol_content)
  end
end