lib/rubocop/cop/style/hash_transform_values.rb in rubocop-0.90.0 vs lib/rubocop/cop/style/hash_transform_values.rb in rubocop-0.91.0
- old
+ new
@@ -29,50 +29,44 @@
include HashTransformMethod
extend AutoCorrector
def_node_matcher :on_bad_each_with_object, <<~PATTERN
(block
- ({send csend}
- !{(send _ :each_with_index) (array ...)}
- :each_with_object (hash))
+ ({send csend} !#array_receiver? :each_with_object (hash))
(args
(mlhs
(arg _key)
(arg $_))
(arg _memo))
- ({send csend} (lvar _memo) :[]= $(lvar _key) $_))
+ ({send csend} (lvar _memo) :[]= $(lvar _key) $!`_memo))
PATTERN
def_node_matcher :on_bad_hash_brackets_map, <<~PATTERN
(send
(const _ :Hash)
:[]
(block
- ({send csend} !(send _ :each_with_index) {:map :collect})
+ ({send csend} !#array_receiver? {:map :collect})
(args
(arg _key)
(arg $_))
(array $(lvar _key) $_)))
PATTERN
def_node_matcher :on_bad_map_to_h, <<~PATTERN
({send csend}
(block
- ({send csend}
- !{(send _ :each_with_index) (array ...)}
- {:map :collect})
+ ({send csend} !#array_receiver? {:map :collect})
(args
(arg _key)
(arg $_))
(array $(lvar _key) $_))
:to_h)
PATTERN
def_node_matcher :on_bad_to_h, <<~PATTERN
(block
- ({send csend}
- !{(send _ :each_with_index) (array ...)}
- :to_h)
+ ({send csend} !#array_receiver? :to_h)
(args
(arg _key)
(arg $_))
(array $(lvar _key) $_))
PATTERN