Showing 39 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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

          case event
          when :open
            options.ui.logger.debug { "download(#{args[0].remote} -> #{args[0].local})" }
            options.on_progress.nil? or options.on_progress.call(:open, args)
          when :close
Severity: Major
Found in lib/ztk/ssh/download.rb and 1 other location - About 3 hrs to fix
lib/ztk/ssh/upload.rb on lines 57..73

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

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

          case event
          when :open
            options.ui.logger.debug { "upload(#{args[0].local} -> #{args[0].remote})" }
            options.on_progress.nil? or options.on_progress.call(:open, args)
          when :close
Severity: Major
Found in lib/ztk/ssh/upload.rb and 1 other location - About 3 hrs to fix
lib/ztk/ssh/download.rb on lines 59..75

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

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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

            def scp_download(remote, local, options={})
              opened = false
              args = []
      
              scp.download!(remote.to_s, local.to_s, options.send(:table)) do |ch, name, sent, total|
      Severity: Major
      Found in lib/ztk/ssh/download.rb and 1 other location - About 2 hrs to fix
      lib/ztk/ssh/upload.rb on lines 77..92

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

      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

            def scp_upload(local, remote, options={})
              opened = false
              args = []
      
              scp.upload!(local.to_s, remote.to_s, options.send(:table)) do |ch, name, sent, total|
      Severity: Major
      Found in lib/ztk/ssh/upload.rb and 1 other location - About 2 hrs to fix
      lib/ztk/ssh/download.rb on lines 79..94

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

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

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                    def gateway_options
                      process_keys
                      options = base_options
              
                      config.proxy_port.nil? or     options.merge!(:port => config.proxy_port)
              Severity: Minor
              Found in lib/ztk/ssh/private.rb and 1 other location - About 55 mins to fix
              lib/ztk/ssh/private.rb on lines 29..38

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

              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

                    def ssh_options
                      process_keys
                      options = base_options
              
                      config.port.nil? or     options.merge!(:port => config.port)
              Severity: Minor
              Found in lib/ztk/ssh/private.rb and 1 other location - About 55 mins to fix
              lib/ztk/ssh/private.rb on lines 42..51

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

              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

              Severity
              Category
              Status
              Source
              Language