Showing 52 of 56 total issues
Method find_record
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def find_record record
subnets.each do |s|
s.records.each do |v|
return v if record.is_a?(String) and (v.ip == record or v.mac == record)
return v if record.is_a?(Proxy::DHCP::Record) and v == record
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method loadSubnetData
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def loadSubnetData subnet
super
conf = format((@config+@leases).split("\n"))
# scan for host statements
conf.scan(/host\s+(\S+\s*\{[^}]+\})/) do |host|
Method run!
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.run!(options={})
set options
handler = detect_rack_handler
handler_name = handler.name.gsub(/.*::/, '')
Method parse_record_options
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse_record_options text
options = {}
case text
# standard record values
when /^hardware\s+ethernet\s+(\S+)/
Method unused_ip
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def unused_ip args = {}
# first check if we already have a record for this host
# if we do, we can simply reuse the same ip address.
if args[:mac] and r=has_mac?(args[:mac])
logger.debug "Found an existing dhcp record #{r}, reusing..."
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method addRecord
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def addRecord options={}
record = super(options)
cmd = "scope #{record.subnet.network} add reservedip #{record.ip} #{record.mac.gsub(/:/,"")} #{record.name}"
execute(cmd, "Added DHCP reservation for #{record}")
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method find_puppetca
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def find_puppetca
ssl_dir = Pathname.new ssldir
unless (ssl_dir + "ca").directory?
logger.warn "PuppetCA: SSL/CA unavailable on this machine: ssldir not found at #{ssl_dir}"
raise "SSL/CA unavailable on this machine"
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method tcp_pingable?
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def tcp_pingable? ip
# This code is from net-ping, and stripped down for use here
# We don't need all the ldap dependencies net-ping brings in
@service_check = true
Method unused_ip
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def unused_ip args = {}
# first check if we already have a record for this host
# if we do, we can simply reuse the same ip address.
if args[:mac] and r=has_mac?(args[:mac])
logger.debug "Found an existing dhcp record #{r}, reusing..."
Method daemon
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.daemon(nochdir = nil, noclose = nil)
exit if fork # Parent exits, child continues.
Process.setsid # Become session leader.
exit if fork # Zap session leader. See [1].
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method bmc_setup
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def bmc_setup
raise "Smart Proxy is not configured to support BMC control" unless SETTINGS.bmc
# Either use the default provider or allow user to specify provider in request
Method execute
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def execute cmd, msg=nil, error_only=false
tsecs = 5
response = nil
interpreter = SETTINGS.x86_64 ? 'c:\windows\sysnative\cmd.exe' : 'c:\windows\system32\cmd.exe'
command = interpreter + ' /c c:\Windows\System32\netsh.exe -c dhcp ' + "server #{name} #{cmd}"
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method find_subnet
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def find_subnet value
subnets.each do |s|
return s if value.is_a?(String) and s.network == value
return s if value.is_a?(Proxy::DHCP::Record) and s.include?(value.ip)
return s if value.is_a?(IPAddr) and s.include?(value)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method load
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def load
Puppet.clear
if Puppet::PUPPETVERSION.to_i >= 3
# Used on Puppet 3.0, private method that clears the "initialized or
# not" state too, so a full config reload takes place and we pick up
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method read_config
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def read_config file
logger.debug "Reading config file #{file}"
config = []
File.readlines(file).each do |line|
if /^include\s+"(.*)"\s*;/ =~ line.strip
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method valid_range
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def valid_range args = {}
logger.debug "trying to find an ip address, we got #{args.inspect}"
if args[:from] and (from=validate_ip(args[:from])) and args[:to] and (to=validate_ip(args[:to]))
raise Proxy::DHCP::Error, "Range does not belong to provided subnet" unless self.include?(from) and self.include?(to)
from = IPAddr.new(from)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method nsupdate
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def nsupdate cmd
status = nil
if cmd == "connect"
find_nsupdate if @nsupdate.nil?
nsupdate_cmd = "#{@nsupdate} #{nsupdate_args}"
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method dns_setup
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def dns_setup(opts)
raise "Smart Proxy is not configured to support DNS" unless SETTINGS.dns
case SETTINGS.dns_provider
when "nsupdate"
require 'proxy/dns/nsupdate'
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method puppet_setup
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def puppet_setup(opts = {})
raise "Smart Proxy is not configured to support Puppet runs" unless SETTINGS.puppet
case SETTINGS.puppet_provider
when "puppetrun"
require 'proxy/puppet/puppetrun'
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method list
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def list
find_puppetca
command = "#{@sudo} -S #{@puppetca} --list --all"
logger.debug "Executing #{command}"
response = `#{command}`
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"