class RuboCop::Cop::Lint::EnsureReturn

end
cleanup
ensure
self
end
# Let’s ignore this exception
rescue SomeException
do_something
begin
def foo
# also good
end
cleanup
ensure
self
do_something
def foo
# good
@example
end
return self
cleanup
ensure
do_something
def foo
# bad
@example
If you want to rescue some (or all) exceptions, best to do it explicitly
and the exception will be silently thrown away as if it were rescued.
will take precedence over any exception being raised,
‘return` from an ensure block is a dangerous code smell as it
This cop checks for `return` from an `ensure` block.

def on_ensure(node)

def on_ensure(node)
  node.body&.each_node(:return) { |return_node| add_offense(return_node) }
end