Class: Pedant::CheckContainsDisplay

Inherits:
Check
  • Object
show all
Defined in:
lib/pedant/checks/contains_display.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



31
32
33
# File 'lib/pedant/checks/contains_display.rb', line 31

def self.requires
  super + [:main, :trees]
end

Instance Method Details

#runObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/pedant/checks/contains_display.rb', line 35

def run
  si_nodes = []
  tree = @kb[:trees][@kb[:main]]

  tree.all(:Call).each do |node|
    next unless node.name.ident.name == 'display'
    next unless node.name.indexes == []
    si_nodes << node
  end
  
  if (si_nodes.length != 0)
    report(:warn, "display() is called:\n" + si_nodes.first.context())
    return warn
  end
  
  pass
end