Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't show a deprecation warning for EnsureNode#branch just yet #339

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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