Ruby

Ruby

Made by DeepSource

return detected inside ensure RB-LI1021

Bug risk
Major

Do not return from an ensure block. If you explicitly return from a method inside an ensure block, the return will take precedence over any exception being raised, and the method will return as if no exception had been raised at all. In effect, the exception will be silently thrown away.

Bad practice

begin
  do_something
ensure
  do_something_else
  return
end

Recommended

begin
  do_something
ensure
  do_something_else
end