class RuboCop::Cop::Lint::NoReturnInBeginEndBlocks


end
do_something
else
some_value
return if another_condition_is_met
some_variable = if some_condition_is_met
# good
end
end
do_something
else
some_value
if some_condition_is_met
@some_variable ||= begin
# good
@example
end
do_something
return some_value if some_condition_is_met
@some_variable ||= begin
# bad
@example
method, possibly leading to unexpected behavior.
In this situation, the ‘return` will result in an exit from the current
in assignment contexts.
Checks for the presence of a `return` inside a `begin..end` block

def on_lvasgn(node)

def on_lvasgn(node)
  node.each_node(:kwbegin) do |kwbegin_node|
    kwbegin_node.each_node(:return) do |return_node|
      add_offense(return_node)
    end
  end
end