Showing 52 of 98 total issues
Method register
has 153 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.register(base)
base.register_simple(:hostname, /^hostname\s+(\S+)$/, 'sh run', 'hostname')
base.register_simple(:ip_domain_name, /^ip\s+domain-name\s+(\S+)$/, 'sh run', 'ip domain-name')
Method register
has 145 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.register(base)
base.register_param ['hardwaremodel', 'processor', 'hardwarerevision', 'memorysize'] do
match /[cC]isco ([\S-]+) (?:\(([\w-]+)\) processor )?\(revision (.+)\) with (\d+[KMG])(?:\/(\d+[KMG]))? bytes of memory\./
cmd "sh ver"
end
Method register
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
def self.register(base)
base.register_simple(:hostname, /^hostname\s+(\S+)$/, 'sh run', 'hostname')
base.register_simple(:ip_domain_name, /^ip\s+domain-name\s+(\S+)$/, 'sh run', 'ip domain-name')
- 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 register
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
def self.register(base)
ifprop(base, :description)
ifprop(base, :mode, "switchport mode")
ifprop(base, :access, "switchport access vlan") do
after :mode
- 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 register
has 112 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.register(base)
ifprop(base, :description)
ifprop(base, :mode, "switchport mode")
ifprop(base, :access, "switchport access vlan") do
after :mode
Method expect
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
def expect(prompt)
line = ''
socket = @ssh.transport.socket
while not eof?
- 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 update
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def update(is = {}, should = {})
return unless configuration_changed?(is, should)
should_present = should[:ensure] == :present
is.delete(:ensure)
- 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 update
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def update(is = {}, should = {})
return unless configuration_changed?(is, should)
before_update
if should[:ensure] == :present
missing_commands = [is.keys, should.keys].flatten.uniq.sort - @params.keys.flatten.uniq.sort
- 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 update
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def update(is = {}, should = {})
return unless configuration_changed?(is, should)
missing_commands = [is.keys, should.keys].flatten.uniq.sort - @params.keys.flatten.uniq.sort
missing_commands.delete(:ensure)
raise Puppet::Error, "Undefined commands for #{missing_commands.join(', ')}" unless missing_commands.empty?
- 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 evaluate_new_params
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def evaluate_new_params
Puppet::Util::NetworkDevice::Sorter.new(@params).tsort.each do |param|
#Skip if the param has already been evaluated
next if param.evaluated
if param.cmd != false
- 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 register
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def self.register(base)
base.register_param ['hardwaremodel', 'processor', 'hardwarerevision', 'memorysize'] do
match /[cC]isco ([\S-]+) (?:\(([\w-]+)\) processor )?\(revision (.+)\) with (\d+[KMG])(?:\/(\d+[KMG]))? bytes of memory\./
cmd "sh ver"
end
- 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 register
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def self.register(base)
snmp_prop(base, :chassis_id, 'snmp-server chassis-id')
snmp_prop(base, :contact, 'snmp-server contact')
snmp_prop(base, :enable_traps, 'snmp-server enable traps') do
match do |txt|
- 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 check_all_attributes
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def check_all_attributes(refreshing = false)
self.class.checks.each { |check|
next if refreshing and check == :refreshonly
if @parameters.include?(check)
val = @parameters[check].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 register
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.register(base)
snmp_prop(base, :chassis_id, 'snmp-server chassis-id')
snmp_prop(base, :contact, 'snmp-server contact')
snmp_prop(base, :enable_traps, 'snmp-server enable traps') do
match do |txt|
Method command
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def command(cmd, options = {})
noop = options[:noop].nil? ? Puppet[:noop] : options[:noop]
if options[:cache]
return @cache[cmd] if @cache[cmd]
send(cmd, noop)
- 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 update
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def update(is = {}, should = {})
# Delete the Property here since we cant really compare params in a propertys validate block
# Puppet Magic...
should.delete(:acl_type)
return unless configuration_changed?(is, should, :keep_ensure => true)
- 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 update
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def update(is = {}, should = {})
return unless configuration_changed?(is, should, :keep_ensure => true)
missing_commands = [is.keys, should.keys].flatten.uniq.sort - @params.keys.flatten.uniq.sort
missing_commands.delete(:ensure)
raise Puppet::Error, "Undefined commands for #{missing_commands.join(', ')}" unless missing_commands.empty?
- 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 newhostprop
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def newhostprop(name, options = {}, &block)
newproperty(name, options) do
# TODO: We should replace this here with a proper Class
# the current handling is just bad
- 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 verify_vtp
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def verify_vtp(device)
# make the switch vtp primary if we try to set vlans on this switch
unless device.switch.facts['vtp_mode'] == 'primary_server'
self.fail("Cant set VLAN's on a VTP Client") if device.switch.facts['vtp_mode'] == 'client'
return if device.switch.facts['vtp_mode'] == 'tranparent'
- 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 register
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.register(base)
base.register_scoped :ensure, /^(aaa\s+group\s+server\s+(?:radius|tacacs\+)\s+(\S+)).*?^!/m do
cmd 'sh run'
match do |txt|
txt.match(/\S+/) ? :present : :absent