class Nucop::OrderedHash

This cop looks for usages of `ActiveSupport::OrderedHash`

Hashes in Ruby (since 1.9) enumerate their keys in the order they are inserted:

“Hashes enumerate their values in the order that the corresponding keys were inserted.” ruby-doc.org/core-2.1.6/Hash.html

@example

# bad

hash = ActiveSupport::OrderedHash.new

# good

hash = {}

Constants

MSG

Public Instance Methods

autocorrect(node) click to toggle source
# File lib/nucop/cops/ordered_hash.rb, line 36
def autocorrect(node)
  ->(corrector) do
    corrector.replace(node.source_range, "{}")
  end
end
on_send(node) click to toggle source
# File lib/nucop/cops/ordered_hash.rb, line 26
def on_send(node)
  ordered_hash_usage(node) do
    add_offense(
      node,
      location: :expression,
      message: MSG
    )
  end
end