Sha256: 648f25969f927a7cc37b609369c1b1d9cef74a073bdf0e4e3074178bd426214e
Contents?: true
Size: 918 Bytes
Versions: 2
Compression:
Stored size: 918 Bytes
Contents
# encoding: utf-8 module Rubocop module Cop module Lint # This cop looks for use of the same name as outer local variables # for block arguments or block local variables. # This is a mimic of the warning # "shadowing outer local variable - foo" from `ruby -cw`. class ShadowingOuterLocalVariable < Cop include VariableInspector MSG = 'Shadowing outer local variable - %s' def investigate(processed_source) inspect_variables(processed_source.ast) end 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 = format(MSG, variable.name) add_offense(variable.declaration_node, :expression, message) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.19.1 | lib/rubocop/cop/lint/shadowing_outer_local_variable.rb |
rubocop-0.19.0 | lib/rubocop/cop/lint/shadowing_outer_local_variable.rb |