Showing 98 of 98 total issues
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
class Puppet::Util::NetworkDevice::Cisco_ios::Model::Interface < Puppet::Util::NetworkDevice::Cisco_ios::Model::Base
attr_reader :params, :name
def initialize(transport, facts, options)
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 77.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
class Puppet::Util::NetworkDevice::Cisco_ios::Model::Line < Puppet::Util::NetworkDevice::Cisco_ios::Model::Base
attr_reader :params, :name
def initialize(transport, facts, options)
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 77.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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
Method perform_update
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def perform_update(is, should)
case @params[:ensure].value
when :present
transport.command("vlan #{name}", :prompt => /\(config-vlan\)#\s?\z/n)
Puppet::Util::NetworkDevice::Sorter.new(@params).tsort.each do |param|
- 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 14 (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 register
has a Cognitive Complexity of 14 (exceeds 5 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
- 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 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.register(base)
base.base_cmd = "radius-server host <%= name %>"
scope = /^(radius-server host (\S+)(.*))/
base.register_scoped :ensure, scope do
Method newipprop
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def newipprop(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 update
has a Cognitive Complexity of 13 (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 connect
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def connect(&block)
begin
Puppet.debug "Trying to connect to #{host} as #{user}"
@ssh = Net::SSH.start(host, user, :port => port, :password => password, :timeout => timeout)
rescue TimeoutError
- 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 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.register(base)
base.base_cmd = "snmp-server community <%= name %>"
snmp_scope = /^(snmp-server community (\S+)(.*))/
base.register_scoped :ensure, snmp_scope do
match do |txt|
Method newipprop
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def newipprop(name, options = {}, &block)
newproperty(name, options) do
# TODO: We should replace this here with a proper Class
# the current handling is just bad
Similar blocks of code found in 3 locations. Consider refactoring. Open
[is.keys, should.keys].flatten.uniq.sort.each do |property|
next if property == :acl_type
next if should[property] == :undef
@params[property].value = :absent if should[property] == :absent || should[property].nil?
@params[property].value = should[property] unless should[property] == :absent || should[property].nil?
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 58.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
[is.keys, should.keys].flatten.uniq.sort.each do |property|
next if property == :acl_type
next if should[property] == :undef
@params[property].value = :absent if should[property] == :absent || should[property].nil?
@params[property].value = should[property] unless should[property] == :absent || should[property].nil?
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 58.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
[is.keys, should.keys].flatten.uniq.sort.each do |property|
next if property == :ensure
next if should[property] == :undef
@params[property].value = :absent if should[property] == :absent || should[property].nil?
@params[property].value = should[property] unless should[property] == :absent || should[property].nil?
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 58.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method register
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.register(base)
base.base_cmd = "username <%= name %>"
scope = /^(username (\S+)(.*))/
base.register_scoped :ensure, scope do
Method update
has a Cognitive Complexity of 11 (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...
return unless configuration_changed?(is, should, :keep_ensure => true)
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 register
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.register(base)
lineprop(base, :access_class, 'access-class') do
match /^\s*access-class\s+(.*)$/
end
Method update
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update(is = {}, should = {})
return unless configuration_changed?(is, should)
should_present = should[:ensure] == :present
is.delete(:ensure)