uniak/puppet-networkdevice

View on GitHub

Showing 98 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')

Severity: Major
Found in lib/puppet/util/network_device/cisco_ios/model/switch/base.rb - About 6 hrs to fix

    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
    Severity: Major
    Found in lib/puppet/util/network_device/cisco_ios/possible_facts/base.rb - About 5 hrs to fix

      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')
      
      
      Severity: Minor
      Found in lib/puppet/util/network_device/cisco_ios/model/switch/base.rb - About 5 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

      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
      Severity: Minor
      Found in lib/puppet/util/network_device/cisco_ios/model/interface/base.rb - About 5 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

      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
      Severity: Major
      Found in lib/puppet/util/network_device/cisco_ios/model/interface/base.rb - About 4 hrs to fix

        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?
        Severity: Minor
        Found in lib/puppet/util/network_device/transport_ios/sshios.rb - About 4 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

        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)
        Severity: Minor
        Found in lib/puppet/util/network_device/cisco_ios/model/acl.rb - About 3 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

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

        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?
        Severity: Minor
        Found in lib/puppet/util/network_device/cisco_ios/model/base.rb - About 3 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

        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
        Severity: Minor
        Found in lib/puppet/util/network_device/dsl.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

        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
        Severity: Minor
        Found in lib/puppet/util/network_device/cisco_ios/possible_facts/base.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

        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|
        Severity: Minor
        Found in lib/puppet/util/network_device/cisco_ios/model/snmp/base.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

        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
        Severity: Minor
        Found in lib/puppet/type/cisco_exec.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

        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|
        Severity: Major
        Found in lib/puppet/util/network_device/cisco_ios/model/snmp/base.rb - About 2 hrs to fix

          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)
          Severity: Minor
          Found in lib/puppet/util/network_device/transport_ios/base_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

          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)
          Severity: Minor
          Found in lib/puppet/util/network_device/cisco_ios/model/snmp_community.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

          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?
          Severity: Minor
          Found in lib/puppet/util/network_device/cisco_ios/model/vlan.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

          module Puppet::Util::NetworkDevice::Cisco_ios::Model::Interface::Hardware::C2960
          
            # TODO: Generalize me!
            def self.ifprop(base, param, base_command = param, &block)
              base.register_scoped param, /^(interface\s+(\S+).*?)^!/m do
          lib/puppet/util/network_device/cisco_ios/model/interface/hardware/c4500.rb on lines 3..30

          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 81.

          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

          module Puppet::Util::NetworkDevice::Cisco_ios::Model::Interface::Hardware::C4500
          
            # TODO: Generalize me!
            def self.ifprop(base, param, base_command = param, &block)
              base.register_scoped param, /^(interface\s+(\S+).*?)^!/m do
          lib/puppet/util/network_device/cisco_ios/model/interface/hardware/c2960.rb on lines 3..30

          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 81.

          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 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
          Severity: Minor
          Found in lib/puppet/util/host_prop.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

          Severity
          Category
          Status
          Source
          Language