From 65cf654ce8060d60beed0ff4b05c48fbde3e59e6 Mon Sep 17 00:00:00 2001 From: Earlopain <14981592+Earlopain@users.noreply.github.com> Date: Wed, 13 Nov 2024 17:37:31 +0100 Subject: [PATCH] Don't show a deprecation warning for `EnsureNode#branch` just yet There currently is no RuboCop version that will not show this warning. --- changelog/fix_dont_emit_deprecation_just_yet.md | 1 + lib/rubocop/ast/node/ensure_node.rb | 13 ------------- 2 files changed, 1 insertion(+), 13 deletions(-) create mode 100644 changelog/fix_dont_emit_deprecation_just_yet.md diff --git a/changelog/fix_dont_emit_deprecation_just_yet.md b/changelog/fix_dont_emit_deprecation_just_yet.md new file mode 100644 index 000000000..789b47783 --- /dev/null +++ b/changelog/fix_dont_emit_deprecation_just_yet.md @@ -0,0 +1 @@ +* [#339](https://github.com/rubocop/rubocop-ast/pull/339): Do not emit a deprecation warning for `EnsureNode#body` to give RuboCop a chance to update its usage. `EnsureNode#body` will still be changed in the next major version of `rubocop-ast`. ([@earlopain][]) diff --git a/lib/rubocop/ast/node/ensure_node.rb b/lib/rubocop/ast/node/ensure_node.rb index ddd9effe1..511632ae4 100644 --- a/lib/rubocop/ast/node/ensure_node.rb +++ b/lib/rubocop/ast/node/ensure_node.rb @@ -6,24 +6,11 @@ module AST # node when the builder constructs the AST, making its methods available # to all `ensure` nodes within RuboCop. class EnsureNode < Node - DEPRECATION_WARNING_LOCATION_CACHE = [] # rubocop:disable Style/MutableConstant - private_constant :DEPRECATION_WARNING_LOCATION_CACHE - # Returns the body of the `ensure` clause. # # @return [Node, nil] The body of the `ensure`. # @deprecated Use `EnsureNode#branch` def body - first_caller = caller(1..1).first - - unless DEPRECATION_WARNING_LOCATION_CACHE.include?(first_caller) - warn '`EnsureNode#body` is deprecated and will be changed in the next major version of ' \ - 'rubocop-ast. Use `EnsureNode#branch` instead to get the body of the `ensure` branch.' - warn "Called from:\n#{caller.join("\n")}\n\n" - - DEPRECATION_WARNING_LOCATION_CACHE << first_caller - end - branch end