class Rubocop::Cop::Lint::ShadowingOuterLocalVariable
“shadowing outer local variable - foo” from ‘ruby -cw`.
This is a mimic of the warning
for block arguments or block local variables.
This cop looks for use of the same name as outer local variables
def before_declaring_variable(variable)
def before_declaring_variable(variable) return if variable.name.to_s.start_with?('_') outer_local_variable = variable_table.find_variable(variable.name) return unless outer_local_variable message = sprintf(MSG, variable.name) warning(variable.declaration_node, :expression, message) end
def investigate(processed_source)
def investigate(processed_source) inspect_variables(processed_source.ast) end