58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/rubocop/cop/lint/shadowing_outer_local_variable.rb', line 58
def before_declaring_variable(variable, variable_table)
return if variable.should_be_unused?
return if ractor_block?(variable.scope.node)
outer_local_variable = variable_table.find_variable(variable.name)
return unless outer_local_variable
return if variable_used_in_declaration_of_outer?(variable, outer_local_variable)
return if same_conditions_node_different_branch?(variable, outer_local_variable)
message = format(MSG, variable: variable.name)
add_offense(variable.declaration_node, message: message)
end
|