Class: Pedant::CheckLocalVariableUnused

Inherits:
Check
  • Object
show all
Defined in:
lib/pedant/checks/local_variable_unused.rb

Instance Attribute Summary

Attributes inherited from Check

#result

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Check

all, depends, #fail, #fatal, friendly_name, inherited, #initialize, initialize!, list, #pass, provides, ready?, #report, run_checks_in_dependency_order, #skip, #warn

Constructor Details

This class inherits a constructor from Pedant::Check

Class Method Details

.requiresObject



29
30
31
# File 'lib/pedant/checks/local_variable_unused.rb', line 29

def self.requires
  super + [:trees]
end

Instance Method Details

#check(file, tree) ⇒ Object



33
34
35
36
37
38
39
40
41
# File 'lib/pedant/checks/local_variable_unused.rb', line 33

def check(file, tree)
  def check_function(id, blk)
    report(:warn, "Function #{id.name} was not analyzed since this check is unfinished.")
  end

  # Local variable statements can technically occur anywhere, they only
  # create new variables when found in functions.
  tree.all(:Function).each { |fn| check_function(fn.name, fn.body) }
end

#check_function(id, blk) ⇒ Object



34
35
36
# File 'lib/pedant/checks/local_variable_unused.rb', line 34

def check_function(id, blk)
  report(:warn, "Function #{id.name} was not analyzed since this check is unfinished.")
end

#runObject



43
44
45
46
47
48
49
# File 'lib/pedant/checks/local_variable_unused.rb', line 43

def run
  # This check will pass by default.
  pass

  # Run this check on the tree from every file.
  @kb[:trees].each { |file, tree| check(file, tree) }
end