class RuboCop::AST::EnsureNode

to all ‘ensure` nodes within RuboCop.
node when the builder constructs the AST, making its methods available
A node extension for `ensure` nodes. This will be used in place of a plain

def body

Deprecated:
  • Use `EnsureNode#branch`

Returns:
  • (Node, nil) - The body of the `ensure`.
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

def branch

Returns:
  • (Node, nil) - the body of the ensure branch.
def branch
  node_parts[1]
end

def rescue_node

Returns:
  • (Node, nil) - The `rescue` node.
def rescue_node
  node_parts[0] if node_parts[0].rescue_type?
end

def void_context?

Returns:
  • (true) - whether the `ensure` node body is a void context
def void_context?
  true
end