uniak/puppet-networkdevice

View on GitHub

Showing 52 of 98 total issues

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

        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

              Method lineprop has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                def self.lineprop(base, param, base_command = param, &block)
                  base.register_scoped param, /^(line\s+((?:con|vty)\s+\d+(?:\s+\d+)?)\s*\n(?:\s[^\n]*\n)*)/ do
                    cmd 'sh run'
                    match /^\s*#{base_command}\s+(.*)$/
                    scope_match do |scope, scope_name|
              Severity: Minor
              Found in lib/puppet/util/network_device/cisco_ios/model/line/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 tsort_each_child has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                def tsort_each_child(param, &block)
                  @param.each_value.select  { |i|
                    next unless i.respond_to?(:before) && i.respond_to?(:after)
                    next unless param.respond_to?(:after)
                    i.before == param.name || i.name == param.after
              Severity: Minor
              Found in lib/puppet/util/network_device/sorter.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 10 (exceeds 5 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|

              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 initialize has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                def initialize(url)
                  @url = URI.parse(url)
                  @query = CGI.parse(@url.query) if @url.query
              
                  require "puppet/util/network_device/transport_ios/#{@url.scheme}"
              Severity: Minor
              Found in lib/puppet/util/network_device/base_ios.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 newhostlistprop has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def newhostlistprop(name, options = {}, &block)
                  # hostlists do array_matching all by default
                  options[:array_matching] ||= :all
              
                  newproperty(name, options) do
              Severity: Minor
              Found in lib/puppet/util/host_list_prop.rb - About 1 hr to fix

                Method connect has 26 lines of code (exceeds 25 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

                  Method register has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def self.register(base)
                      base.base_cmd = "snmp-server host <%= name %>"
                      snmp_scope = /^(snmp-server host (\S+)(.*))/
                      base.register_scoped :ensure, snmp_scope do
                        match do |txt|
                  Severity: Minor
                  Found in lib/puppet/util/network_device/cisco_ios/model/snmp_host/base.rb - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language