ripta/drydock

View on GitHub

Showing 240 of 240 total issues

Cyclomatic complexity for set is too high. [7/6]
Open

    def set(key, value = nil, &blk)
      key = key.to_sym
      fail ArgumentError, "unknown option #{key.inspect}" unless build_opts.key?(key)
      fail ArgumentError, 'one of value or block is required' if value.nil? && blk.nil?
      fail ArgumentError, 'only one of value or block may be provided' if value && blk
Severity: Minor
Found in lib/drydock/project.rb by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Assignment Branch Condition size for build_tar_from_source! is too high. [16.31/15]
Open

      def build_tar_from_source!
        buffer = StringIO.new
        log_info("Processing #{source_files.size} files in tree")

        TarWriter.new(buffer) do |tar|
Severity: Minor
Found in lib/drydock/instructions/copy.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method add has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def add(severity, message = nil, progname = nil, &block)
      annotation = nil
      indent     = 0

      if message.nil?
Severity: Minor
Found in lib/drydock/logger.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 parse! has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def self.parse!(args)
      opts = new

      parser = OptionParser.new do |cfg|
        cfg.banner = "Usage: #{$PROGRAM_NAME} [options...] [drydock-filename]"
Severity: Minor
Found in lib/drydock/runtime_options.rb - About 1 hr to fix

    Method find has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.find(path, ignorefile, prepend_path: false, recursive: true)
          path = path.sub(%r{/$}, '')
    
          [].tap do |results|
            ::Find.find(path) do |subpath|
    Severity: Minor
    Found in lib/drydock/file_manager.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 add has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def add(severity, message = nil, progname = nil, &block)
          annotation = nil
          indent     = 0
    
          if message.nil?
    Severity: Minor
    Found in lib/drydock/logger.rb - About 1 hr to fix

      Block has too many lines. [35/25]
      Open

            parser = OptionParser.new do |cfg|
              cfg.banner = "Usage: #{$PROGRAM_NAME} [options...] [drydock-filename]"
      
              cfg.separator ''
              cfg.separator 'Runtime / build options:'
      Severity: Minor
      Found in lib/drydock/runtime_options.rb by rubocop

      This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

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

          def to_h
            {}.tap do |commit|
              if opts.key?(:command)
                commit['run'] ||= {}
                commit['run'][:Cmd] = opts[:command]
      Severity: Minor
      Found in lib/drydock/commit_options.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 initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def initialize(file_or_filename, dotfiles: false)
            @dotfiles = dotfiles
      
            if file_or_filename.respond_to?(:readlines)
              patterns = Array(file_or_filename.readlines)
      Severity: Minor
      Found in lib/drydock/ignorefile_definition.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 propagate_config! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.propagate_config!(src_image, config_name, opts, opt_key)
            if opts.key?(opt_key)
              Drydock.logger.info("Command override: #{opts[opt_key].inspect}")
            else
              src_image.refresh!
      Severity: Minor
      Found in lib/drydock/phase_chain.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 write_to_container has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def write_to_container(buffer, digest)
              label = "# COPY #{recursive ? 'dir' : 'file'}:md5:#{digest} TO #{target_path}"
      
              chain.run(label, no_cache: no_cache) do |container|
                target_stat = container.archive_head(target_path)
      Severity: Minor
      Found in lib/drydock/instructions/copy.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 archive_head has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def archive_head(path = '/', &blk)
            query = { 'path' => path }
            response = connection.raw_request(:head, path_for(:archive), query, response_block: blk)
      
            return if response.nil?
      Severity: Minor
      Found in lib/drydock/docker_api_patch.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 too many return statements within this method.
      Open

            return false if self['Tty'] != other['Tty']
      Severity: Major
      Found in lib/drydock/container_config.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

              return false if (self['Labels'] || {}) != (other['Labels'] || {})
        Severity: Major
        Found in lib/drydock/container_config.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                return false if Array(self['Env']).sort != Array(other['Env']).sort
          Severity: Major
          Found in lib/drydock/container_config.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                  return true
            Severity: Major
            Found in lib/drydock/container_config.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                    return false if self['Cmd'] != other['Cmd']
              Severity: Major
              Found in lib/drydock/container_config.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                        return false unless other_vols.key?(my_vol)
                Severity: Major
                Found in lib/drydock/container_config.rb - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                          return false unless other_ports.key?(my_port)
                  Severity: Major
                  Found in lib/drydock/container_config.rb - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                          return false if self['Entrypoint'] != other['Entrypoint']
                    Severity: Major
                    Found in lib/drydock/container_config.rb - About 30 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language