Showing 21 of 39 total issues

Method exec has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
Open

      def exec(command, options={})
        options = OpenStruct.new(config.send(:table).merge(options))

        options.ui.logger.debug { "config=#{options.send(:table).inspect}" }
        options.ui.logger.debug { "options=#{options.send(:table).inspect}" }
Severity: Minor
Found in lib/ztk/command/exec.rb - About 7 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 exec has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

      def exec(command, options={})
        options = OpenStruct.new(config.send(:table).merge(options))

        options.ui.logger.debug { "config=#{config.send(:table).inspect}" }
        options.ui.logger.debug { "options=#{options.send(:table).inspect}" }
Severity: Minor
Found in lib/ztk/ssh/exec.rb - About 6 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 exec has 85 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def exec(command, options={})
        options = OpenStruct.new(config.send(:table).merge(options))

        options.ui.logger.debug { "config=#{options.send(:table).inspect}" }
        options.ui.logger.debug { "options=#{options.send(:table).inspect}" }
Severity: Major
Found in lib/ztk/command/exec.rb - About 3 hrs to fix

    Method exec has 84 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def exec(command, options={})
            options = OpenStruct.new(config.send(:table).merge(options))
    
            options.ui.logger.debug { "config=#{config.send(:table).inspect}" }
            options.ui.logger.debug { "options=#{options.send(:table).inspect}" }
    Severity: Major
    Found in lib/ztk/ssh/exec.rb - About 3 hrs to fix

      Method process has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def process(&block)
            !block_given? and log_and_raise(ParallelError, "You must supply a block to the process method!")
      
            config.ui.logger.debug { "forks(#{@forks.inspect})" }
      
      
      Severity: Minor
      Found in lib/ztk/parallel.rb - About 1 hr to fix

        Method process has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def process(&block)
              !block_given? and log_and_raise(ParallelError, "You must supply a block to the process method!")
        
              config.ui.logger.debug { "forks(#{@forks.inspect})" }
        
        
        Severity: Minor
        Found in lib/ztk/parallel.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 list has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

              def list(dataset, headers, &block)
                !block_given? and log_and_raise(ReportError, "You must supply a block!")
                headers.nil? and log_and_raise(ReportError, "Headers can not be nil!")
                dataset.nil? and log_and_raise(ReportError, "Dataset can not be nil!")
        
        
        Severity: Minor
        Found in lib/ztk/report/list.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 ready? has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def ready?
              config.host.nil? and log_and_raise(TCPSocketCheckError, "You must supply a host!")
              config.port.nil? and log_and_raise(TCPSocketCheckError, "You must supply a port!")
        
              socket = TCPSocket.new(config.host, config.port)
        Severity: Minor
        Found in lib/ztk/tcp_socket_check.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 try has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

              def try(options={}, &block)
                options = Base.build_config({
                  :tries => 1,
                  :on => Exception,
                  :delay => 1,
        Severity: Minor
        Found in lib/ztk/rescue_retry.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 spreadsheet has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def spreadsheet(dataset, headers, &block)
                !block_given? and log_and_raise(ReportError, "You must supply a block!")
                headers.nil? and log_and_raise(ReportError, "Headers can not be nil!")
                dataset.nil? and log_and_raise(ReportError, "Dataset can not be nil!")
        
        
        Severity: Minor
        Found in lib/ztk/report/spreadsheet.rb - About 1 hr to fix

          Method list has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def list(dataset, headers, &block)
                  !block_given? and log_and_raise(ReportError, "You must supply a block!")
                  headers.nil? and log_and_raise(ReportError, "Headers can not be nil!")
                  dataset.nil? and log_and_raise(ReportError, "Dataset can not be nil!")
          
          
          Severity: Minor
          Found in lib/ztk/report/list.rb - About 1 hr to fix

            Method belongs_to has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def belongs_to(key, options={})
                    belongs_to_relations[key] = {
                      :class_name => key.to_s.classify,
                      :key => key
                    }.merge(options)
            Severity: Minor
            Found in lib/ztk/dsl/core/relations/belongs_to.rb - About 1 hr to fix

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

                    def attribute(key, options={})
                      klass = self.to_s.split('::').last.downcase
                      option_key = "#{klass}_#{key}"
                      attribute_options[option_key] = options
              
              
              Severity: Minor
              Found in lib/ztk/dsl/core/attributes.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 spreadsheet has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                    def spreadsheet(dataset, headers, &block)
                      !block_given? and log_and_raise(ReportError, "You must supply a block!")
                      headers.nil? and log_and_raise(ReportError, "Headers can not be nil!")
                      dataset.nil? and log_and_raise(ReportError, "Dataset can not be nil!")
              
              
              Severity: Minor
              Found in lib/ztk/report/spreadsheet.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 belongs_to has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                    def belongs_to(key, options={})
                      belongs_to_relations[key] = {
                        :class_name => key.to_s.classify,
                        :key => key
                      }.merge(options)
              Severity: Minor
              Found in lib/ztk/dsl/core/relations/belongs_to.rb - About 55 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 add has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def add(severity, message=nil, progname=nil, shift=0, &block)
              Severity: Minor
              Found in lib/ztk/logger.rb - About 35 mins to fix

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

                      def bench(options={}, &block)
                        options = Base.build_config({
                          :use_spinner => true
                        }, options)
                
                
                Severity: Minor
                Found in lib/ztk/benchmark.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 method_missing has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                      def method_missing(method_name, *method_args)
                        raise "You must supply a block to the profiler method #{method_name.inspect}!" unless block_given?
                
                        @@start_time ||= Time.now.utc
                
                
                Severity: Minor
                Found in lib/ztk/profiler/core.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 wait has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def wait(flags=0)
                      config.ui.logger.debug { "wait" }
                      config.ui.logger.debug { "forks(#{@forks.inspect})" }
                
                      return nil if @forks.count <= 0
                Severity: Minor
                Found in lib/ztk/parallel.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 build_ansi_methods has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def build_ansi_methods(hash)
                      hash.each do |key, value|
                
                        define_method(key) do |string=nil, &block|
                          result = Array.new
                Severity: Minor
                Found in lib/ztk/ansi.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