From d361dcd124d908a4efccf8a91cf432e3b175d09f Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Mon, 24 Jun 2024 18:41:39 +0900 Subject: [PATCH] Lift the deprecation from `ArrayNode#each_value` This PR lifts the deprecation from `ArrayNode#each_value` for the following reasons: 1. `HashNode#each_value` and `HashNode#each_key` are not deprecated. - `HashNode#each_value` ... https://github.com/rubocop/rubocop-ast/blob/v1.31.3/lib/rubocop/ast/node/hash_node.rb#L76-L89 - `HashNode#each_key` ... https://github.com/rubocop/rubocop-ast/blob/v1.31.3/lib/rubocop/ast/node/hash_node.rb#L52-L65 2. `node.values.each` is recommended by `Style/HashEachMethods` cop to be replaced with `each_value` instead of `values.each`. And `node.each_value do |value|` is clearer in intent than `node.children.each do |value|`. Since it is a soft deprecation in documentation only, it has not been added to the changelog. --- lib/rubocop/ast/node/array_node.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/rubocop/ast/node/array_node.rb b/lib/rubocop/ast/node/array_node.rb index 43cf97e3a..19c9a507a 100644 --- a/lib/rubocop/ast/node/array_node.rb +++ b/lib/rubocop/ast/node/array_node.rb @@ -17,7 +17,11 @@ class ArrayNode < Node # @return [Array] an array of value nodes alias values children - # @deprecated Use `values.each` (a.k.a. `children.each`) + # Calls the given block for each `value` node in the `array` literal. + # If no block is given, an `Enumerator` is returned. + # + # @return [self] if a block is given + # @return [Enumerator] if no block is given def each_value(&block) return to_enum(__method__) unless block