Class: Nitpick::LocalVariableNitpicker
- Inherits:
-
LocalVariableCounter
- Object
- SexpProcessor
- Nitpicker
- LocalVariableCounter
- Nitpick::LocalVariableNitpicker
- Defined in:
- lib/nitpick/local_variable_nitpicker.rb
Instance Attribute Summary
Attributes inherited from Nitpicker
Instance Method Summary collapse
Methods inherited from LocalVariableCounter
#call, #initialize, #process_args, #process_block_arg, #process_call, #process_iasgn, #process_lasgn, #process_lvar, #use, #uses
Methods inherited from Nitpicker
#initialize, #process_cfunc, #process_defn, #scan_for, #warn
Constructor Details
This class inherits a constructor from Nitpick::LocalVariableCounter
Instance Method Details
#nitpick! ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/nitpick/local_variable_nitpicker.rb', line 3 def nitpick! super @lvars.each do |name, details| next if @args.include? name next if details[:calls] > 0 # The first assignment is a use next if details[:uses] > 1 warn Warnings::UnusedVariable.new(name) end end |
#process_iter(exp) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/nitpick/local_variable_nitpicker.rb', line 15 def process_iter(exp) call = process(exp.shift) assignments = process(exp.shift) block = process(exp.shift) scan_for [Warnings::ShadowedVariable], :with => [assignments] s(:iter, call, assignments, block) end |