uniak/puppet-networkdevice

View on GitHub

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'
Severity: Minor
Found in lib/puppet/provider/cisco_vlan/cisco_ios.rb - About 2 hrs to fix

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)
Severity: Major
Found in lib/puppet/util/network_device/cisco_ios/model/interface.rb and 1 other location - About 2 hrs to fix
lib/puppet/util/network_device/cisco_ios/model/line.rb on lines 6..44

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

Further Reading

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)
Severity: Major
Found in lib/puppet/util/network_device/cisco_ios/model/line.rb and 1 other location - About 2 hrs to fix
lib/puppet/util/network_device/cisco_ios/model/interface.rb on lines 6..44

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

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
Severity: Minor
Found in lib/puppet/util/network_device/cisco_ios/model/aaa_group/base.rb - About 1 hr to fix

    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|
    Severity: Minor
    Found in lib/puppet/util/network_device/cisco_ios/model/vlan.rb - About 1 hr to fix

    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?
    Severity: Minor
    Found in lib/puppet/util/network_device/cisco_ios/model/radius_server.rb - About 1 hr to fix

    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
    Severity: Minor
    Found in lib/puppet/util/network_device/cisco_ios/model/aaa_group/base.rb - About 1 hr to fix

    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
      Severity: Minor
      Found in lib/puppet/util/ip_prop.rb - About 1 hr to fix

      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?
      Severity: Minor
      Found in lib/puppet/util/network_device/cisco_ios/model/user.rb - About 1 hr to fix

      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
      Severity: Minor
      Found in lib/puppet/util/network_device/transport_ios/sshios.rb - About 1 hr to fix

      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
        Severity: Minor
        Found in lib/puppet/util/ip_prop.rb - About 1 hr to fix

          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?
          lib/puppet/util/network_device/cisco_ios/model/base.rb on lines 21..26
          lib/puppet/util/network_device/cisco_ios/model/vlan.rb on lines 24..29

          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

          Further Reading

          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?
          Severity: Major
          Found in lib/puppet/util/network_device/cisco_ios/model/vlan.rb and 2 other locations - About 1 hr to fix
          lib/puppet/util/network_device/cisco_ios/model/base.rb on lines 21..26
          lib/puppet/util/network_device/cisco_ios/model/snmp_community.rb on lines 35..40

          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

          Further Reading

          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?
          Severity: Major
          Found in lib/puppet/util/network_device/cisco_ios/model/base.rb and 2 other locations - About 1 hr to fix
          lib/puppet/util/network_device/cisco_ios/model/snmp_community.rb on lines 35..40
          lib/puppet/util/network_device/cisco_ios/model/vlan.rb on lines 24..29

          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

          Further Reading

          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
          Severity: Minor
          Found in lib/puppet/util/network_device/cisco_ios/model/user/base.rb - About 1 hr to fix

            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
            Severity: Minor
            Found in lib/puppet/util/network_device/cisco_ios/model/snmp_host.rb - About 1 hr to fix

            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
            
            
            Severity: Minor
            Found in lib/puppet/util/network_device/cisco_ios/model/line/base.rb - About 1 hr to fix

              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)
              Severity: Minor
              Found in lib/puppet/util/network_device/cisco_ios/model/acl.rb - About 1 hr to fix
                Severity
                Category
                Status
                Source
                Language