File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -6,11 +6,24 @@ module AST
6
6
# node when the builder constructs the AST, making its methods available
7
7
# to all `ensure` nodes within RuboCop.
8
8
class EnsureNode < Node
9
+ DEPRECATION_WARNING_LOCATION_CACHE = [ ] # rubocop:disable Style/MutableConstant
10
+ private_constant :DEPRECATION_WARNING_LOCATION_CACHE
11
+
9
12
# Returns the body of the `ensure` clause.
10
13
#
11
14
# @return [Node, nil] The body of the `ensure`.
12
15
# @deprecated Use `EnsureNode#branch`
13
16
def body
17
+ first_caller = caller ( 1 ..1 ) . first
18
+
19
+ unless DEPRECATION_WARNING_LOCATION_CACHE . include? ( first_caller )
20
+ warn '`EnsureNode#body` is deprecated and will be changed in the next major version of ' \
21
+ 'rubocop-ast. Use `EnsureNode#branch` instead to get the body of the `ensure` branch.'
22
+ warn "Called from:\n #{ caller . join ( "\n " ) } \n \n "
23
+
24
+ DEPRECATION_WARNING_LOCATION_CACHE << first_caller
25
+ end
26
+
14
27
branch
15
28
end
16
29
You can’t perform that action at this time.
0 commit comments