ripta/drydock

View on GitHub

Showing 240 of 240 total issues

Assignment Branch Condition size for add is too high. [23.04/15]
Open

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

      if message.nil?
Severity: Minor
Found in lib/drydock/logger.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

Assignment Branch Condition size for raw_request is too high. [22.16/15]
Open

    def raw_request(*args, &block)
      request = compile_request_params(*args, &block)
      log_request(request)
      resource.request(request)
    rescue Excon::Errors::BadRequest => ex
Severity: Minor
Found in lib/drydock/docker_api_patch.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

Assignment Branch Condition size for add_entry is too high. [22.45/15]
Open

    def add_entry(name, mode: 0644, mtime: Time.now, _uid: 0, _gid: 0)
      check_closed

      fail Gem::Package::NonSeekableIO unless @io.respond_to?(:pos=)

Severity: Minor
Found in lib/drydock/tar_writer.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

Assignment Branch Condition size for build is too high. [22.38/15]
Open

  def self.build(build_opts = {}, &blk)
    Project.new(build_opts).tap do |project|
      dryfile, dryfilename = yield project

      Dir.chdir(File.dirname(dryfilename))
Severity: Minor
Found in lib/drydock/drydock.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

Assignment Branch Condition size for to_h is too high. [22.2/15]
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 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

Assignment Branch Condition size for run_with_spool! is too high. [21.21/15]
Open

      def run_with_spool!
        spool_file = Tempfile.new('drydock')
        log_info("Spooling to #{spool_file.path}")

        source_chain.run("# EXPORT #{path}", no_commit: true) do |source_container|
Severity: Minor
Found in lib/drydock/instructions/import.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

Assignment Branch Condition size for write_to_container is too high. [21.31/15]
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 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 run has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def run(cmd, opts = {})
      src_image = last ? last.result_image : @from
      no_commit = opts.fetch(:no_commit, false)

      no_cache = opts.fetch(:no_cache, false)
Severity: Major
Found in lib/drydock/phase_chain.rb - About 2 hrs to fix

    Assignment Branch Condition size for download_once is too high. [20.12/15]
    Open

        def download_once(source_url, target_path, chmod: 0644)
          requires_from!(:download_once)
    
          unless cache.key?(source_url)
            cache.set(source_url) do |obj|
    Severity: Minor
    Found in lib/drydock/project.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

    Cyclomatic complexity for create_container is too high. [11/6]
    Open

        def self.create_container(cfg, &blk)
          meta_options = cfg[:MetaOptions] || {}
          timeout = meta_options.fetch(:read_timeout, Excon.defaults[:read_timeout]) || 60
    
          Drydock.logger.debug(message: "Create container configuration: #{cfg.inspect}")
    Severity: Minor
    Found in lib/drydock/phase_chain.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.

    Perceived complexity for add is too high. [12/7]
    Open

        def add(severity, message = nil, progname = nil, &block)
          annotation = nil
          indent     = 0
    
          if message.nil?
    Severity: Minor
    Found in lib/drydock/logger.rb by rubocop

    This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

    Example:

    def my_method                   # 1
      if cond                       # 1
        case var                    # 2 (0.8 + 4 * 0.2, rounded)
        when 1 then func_one
        when 2 then func_two
        when 3 then func_three
        when 4..10 then func_other
        end
      else                          # 1
        do_something until a && b   # 2
      end                           # ===
    end                             # 7 complexity points

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

        def to_h
          to_container_config.tap do |cc|
            env = Array(opts[:env])
            cc[:Env].push(*env) unless env.empty?
    
    
    Severity: Minor
    Found in lib/drydock/container_options.rb - About 2 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

    Perceived complexity for create_container is too high. [10/7]
    Open

        def self.create_container(cfg, &blk)
          meta_options = cfg[:MetaOptions] || {}
          timeout = meta_options.fetch(:read_timeout, Excon.defaults[:read_timeout]) || 60
    
          Drydock.logger.debug(message: "Create container configuration: #{cfg.inspect}")
    Severity: Minor
    Found in lib/drydock/phase_chain.rb by rubocop

    This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

    Example:

    def my_method                   # 1
      if cond                       # 1
        case var                    # 2 (0.8 + 4 * 0.2, rounded)
        when 1 then func_one
        when 2 then func_two
        when 3 then func_three
        when 4..10 then func_other
        end
      else                          # 1
        do_something until a && b   # 2
      end                           # ===
    end                             # 7 complexity points

    Method has too many lines. [23/20]
    Open

        def download_once(source_url, target_path, chmod: 0644)
          requires_from!(:download_once)
    
          unless cache.key?(source_url)
            cache.set(source_url) do |obj|
    Severity: Minor
    Found in lib/drydock/project.rb by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Assignment Branch Condition size for import is too high. [18.36/15]
    Open

        def import(path, from: nil, force: false, spool: false)
          mkdir(path)
    
          requires_from!(:import)
          fail InvalidInstructionError, 'cannot `import` from `/`' if path == '/' && !force
    Severity: Minor
    Found in lib/drydock/project.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 has too many lines. [23/20]
    Open

        def ==(other)
          return false if other.nil?
    
          return false if self['OpenStdin'] || other['OpenStdin']
          return false if self['AttachStdout'] != other['AttachStdout']
    Severity: Minor
    Found in lib/drydock/container_config.rb by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Method create_container has 50 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def self.create_container(cfg, &blk)
          meta_options = cfg[:MetaOptions] || {}
          timeout = meta_options.fetch(:read_timeout, Excon.defaults[:read_timeout]) || 60
    
          Drydock.logger.debug(message: "Create container configuration: #{cfg.inspect}")
    Severity: Minor
    Found in lib/drydock/phase_chain.rb - About 2 hrs to fix

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

            Docker::Container.create(cfg).tap do |c|
              # The call to Container.create merely creates a container, to be
              # scheduled to run. Start a separate thread that attaches to the
              # container's streams and mirror them to the logger.
              t = Thread.new do
      Severity: Minor
      Found in lib/drydock/phase_chain.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.

      Cyclomatic complexity for add is too high. [8/6]
      Open

          def add(severity, message = nil, progname = nil, &block)
            annotation = nil
            indent     = 0
      
            if message.nil?
      Severity: Minor
      Found in lib/drydock/logger.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 finalize! is too high. [16.31/15]
      Open

          def finalize!(force: false)
            return self if finalized?
      
            children.reverse_each { |c| c.finalize!(force: force) } if children
            ephemeral_containers.reverse_each { |c| c.remove(force: force) }
      Severity: Minor
      Found in lib/drydock/phase_chain.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

      Severity
      Category
      Status
      Source
      Language