Class: Pedant::CheckContainsIpAddressLiterals

Inherits:
Check
  • Object
show all
Defined in:
lib/pedant/checks/contains_ip_address_literals.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, #skip, #warn

Constructor Details

This class inherits a constructor from Pedant::Check

Class Method Details

.requiresObject



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

def self.requires
  super + [:trees]
end

Instance Method Details

#check(file, tree) ⇒ Object



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

def check(file, tree)
  return if tree.all(:Ip).empty?

  warn
  report(:warn, "IP address literals were found in #{file}.")
  tree.all(:Ip).each { |ip| report(:warn, ip.context) }
end

#runObject



41
42
43
44
45
46
47
# File 'lib/pedant/checks/contains_ip_address_literals.rb', line 41

def run
  # This check will pass by default.
  pass

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