uniak/puppet-networkdevice

View on GitHub

Showing 52 of 98 total issues

Method define_value_method has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def define_value_method(methods)
    methods.each do |meth|
      define_method(meth) do |*args, &block|
        # return the current value if we are called like an accessor
        return instance_variable_get("@#{meth}".to_sym) if args.empty? && block.nil?
Severity: Minor
Found in lib/puppet/util/network_device/value_helper.rb - About 45 mins 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

Avoid deeply nested control flow statements.
Open

          yield nil if block_given?
Severity: Major
Found in lib/puppet/util/network_device/transport_ios/sshios.rb - About 45 mins to fix

    Method newhostlistprop has a Cognitive Complexity of 8 (exceeds 5 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 45 mins 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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def initialize(name, transport, facts = nil, idx = 0, &block)
    Severity: Minor
    Found in lib/puppet/util/network_device/cisco_ios/fact.rb - About 35 mins to fix

      Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        def initialize(name, transport, facts, idx, &block)
      Severity: Minor
      Found in lib/puppet/util/network_device/cisco_ios/model/generic_value.rb - About 35 mins to fix

        Method register_array has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          def register_array(param, match_re, fetch_cmd, cmd, &block)
        Severity: Minor
        Found in lib/puppet/util/network_device/dsl.rb - About 35 mins to fix

          Method parse has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def parse(txt)
              if self.match.is_a?(Proc)
                self.value = self.match.call(txt)
              else
                self.value = txt.scan(self.match).flatten[self.idx]
          Severity: Minor
          Found in lib/puppet/util/network_device/cisco_ios/fact.rb - About 35 mins 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 params_to_hash has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def params_to_hash
              @params.inject({}) {|res, data|
                unless respond_to?(:skip_params_to_hash) && skip_params_to_hash.include?(data[0])
                  unless data[1].value.nil? || data[1].value.to_s.empty?
                    if data[1].value.is_a?(Hash)
          Severity: Minor
          Found in lib/puppet/util/network_device/dsl.rb - About 35 mins 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 extract_scope has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def extract_scope(txt)
              raise "No scope_name configured" if @scope_name.nil?
              return if txt.nil? || txt.empty?
          
              munged = txt.scan(scope).collect do |content,name|
          Severity: Minor
          Found in lib/puppet/util/network_device/cisco_ios/model/scoped_value.rb - About 25 mins 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_new_module has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def register_new_module(mod, path_addition = "")
              @included_modules ||= []
              unless @included_modules.include?(mod)
                Puppet::Util::Autoload.new(self, File.join(mod_path_base, path_addition), :wrap => false).load(mod)
                if path_addition.empty?
          Severity: Minor
          Found in lib/puppet/util/network_device/dsl.rb - About 25 mins 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 change_to_s has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                def change_to_s(current_value, newvalue)
                  begin
                    if current_value == :absent
                      return "defined '#{name}' as #{self.class.format_value_for_display should_to_s(newvalue)}"
                    elsif newvalue == :absent
          Severity: Minor
          Found in lib/puppet/util/ip_prop.rb - About 25 mins 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 expect has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def expect(prompt)
                lines = ''
                @telnet.waitfor(prompt) do |out|
                  lines << out.gsub(/\r\n/no, "\n")
                  yield out if block_given?
          Severity: Minor
          Found in lib/puppet/util/network_device/transport_ios/telnet.rb - About 25 mins 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