Skip to content

Commit

Permalink
Don't show a deprecation warning for EnsureNode#branch just yet
Browse files Browse the repository at this point in the history
There currently is no RuboCop version that will not show this warning.
  • Loading branch information
Earlopain authored and marcandre committed Nov 13, 2024
1 parent fcb7a29 commit 3a7c069
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 13 deletions.
1 change: 1 addition & 0 deletions changelog/fix_dont_emit_deprecation_just_yet.md
Original file line number Diff line number Diff line change
@@ -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][])
13 changes: 0 additions & 13 deletions lib/rubocop/ast/node/ensure_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 3a7c069

Please sign in to comment.