Class: Nucop::OrderedHash
- Inherits:
-
RuboCop::Cop::Base
- Object
- RuboCop::Cop::Base
- Nucop::OrderedHash
- Extended by:
- RuboCop::Cop::AutoCorrector
- Defined in:
- lib/nucop/cops/ordered_hash.rb
Overview
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
Constant Summary collapse
- MSG =
"Ruby hashes after 1.9 enumerate keys in order of insertion"
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/nucop/cops/ordered_hash.rb', line 28 def on_send(node) ordered_hash_usage(node) do add_offense(node, message: MSG) do |corrector| corrector.replace(node.source_range, "{}") end end end |