swipely/docker-api

View on GitHub

Showing 23 of 23 total issues

Class Image has 30 methods (exceeds 20 allowed). Consider refactoring.
Open

class Docker::Image
  include Docker::Base

  # Given a command and optional list of streams to attach to, run a command on
  # an Image. This will not modify the Image, but rather create a new Container
Severity: Minor
Found in lib/docker/image.rb - About 3 hrs to fix

    Class Container has 27 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Docker::Container
      include Docker::Base
    
      # Update the @info hash, which is the only mutable state in this object.
      #   e.g. if you would like a live status from the #info hash, call #refresh! first.
    Severity: Minor
    Found in lib/docker/container.rb - About 3 hrs to fix

      Method request has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

        def request(*args, &block)
          retries ||= 0
          request = compile_request_params(*args, &block)
          log_request(request)
          begin
      Severity: Minor
      Found in lib/docker/connection.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

      File container.rb has 261 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      class Docker::Container
        include Docker::Base
      
        # Update the @info hash, which is the only mutable state in this object.
        #   e.g. if you would like a live status from the #info hash, call #refresh! first.
      Severity: Minor
      Found in lib/docker/container.rb - About 2 hrs to fix

        File image.rb has 258 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        class Docker::Image
          include Docker::Base
        
          # Given a command and optional list of streams to attach to, run a command on
          # an Image. This will not modify the Image, but rather create a new Container
        Severity: Minor
        Found in lib/docker/image.rb - About 2 hrs to fix

          Method request has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def request(*args, &block)
              retries ||= 0
              request = compile_request_params(*args, &block)
              log_request(request)
              begin
          Severity: Minor
          Found in lib/docker/connection.rb - About 1 hr to fix

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

              def exec(command, options = {}, &block)
                # Establish values
                tty = options.delete(:tty) || false
                detach = options.delete(:detach) || false
                user = options.delete(:user)
            Severity: Minor
            Found in lib/docker/container.rb - About 1 hr to fix

              Method hijack_for has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def hijack_for(stdin, block, msg_stack, tty)
                  attach_block = attach_for(block, msg_stack, tty)
              
                  lambda do |socket|
                    debug "hijack: hijacking the HTTP socket"
              Severity: Minor
              Found in lib/docker/util.rb - About 1 hr to fix

                Method create_tar has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                  def create_tar(hash = {})
                    output = StringIO.new
                    Gem::Package::TarWriter.new(output) do |tar|
                      hash.each do |file_name, file_details|
                        permissions = file_details.is_a?(Hash) ? file_details[:permissions] : 0640
                Severity: Minor
                Found in lib/docker/util.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 docker_context has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                  def docker_context(directory)
                    all_files = glob_all_files(File.join(directory, "**/*"))
                    dockerignore = File.join(directory, '.dockerignore')
                    return all_files unless all_files.include?(dockerignore)
                
                
                Severity: Minor
                Found in lib/docker/util.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

                            Docker.logger.warn(
                              <<~RETRY_WARNING
                              Automatically retrying with content type '#{response_cause}'
                                Original Error: #{ex}
                              RETRY_WARNING
                Severity: Major
                Found in lib/docker/connection.rb - About 45 mins to fix

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

                      def build_from_tar(tar, opts = {}, connection = Docker.connection,
                                         creds = nil, &block)
                  Severity: Minor
                  Found in lib/docker/image.rb - About 35 mins to fix

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

                        def build_from_dir(dir, opts = {}, connection = Docker.connection,
                                           creds = nil, &block)
                    Severity: Minor
                    Found in lib/docker/image.rb - About 35 mins to fix

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

                          def load(tar, opts = {}, conn = Docker.connection, creds = nil, &block)
                      Severity: Minor
                      Found in lib/docker/image.rb - About 35 mins to fix

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

                          def add_file_to_tar(tar, name, mode, size, mtime)
                        Severity: Minor
                        Found in lib/docker/util.rb - About 35 mins to fix

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

                            def compile_request_params(http_method, path, query = nil, opts = nil, &block)
                          Severity: Minor
                          Found in lib/docker/connection.rb - About 35 mins to fix

                            Method file_hash_from_paths has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def file_hash_from_paths(local_paths)
                                local_paths.each_with_object({}) do |local_path, file_hash|
                                  unless File.exist?(local_path)
                                    raise ArgumentError, "#{local_path} does not exist."
                                  end
                            Severity: Minor
                            Found in lib/docker/util.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 create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def create(opts = {}, creds = nil, conn = Docker.connection, &block)
                                  credentials = creds.nil? ? Docker.creds : MultiJson.dump(creds)
                                  headers = credentials && Docker::Util.build_auth_header(credentials) || {}
                                  body = ''
                                  conn.post(
                            Severity: Minor
                            Found in lib/docker/image.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 hijack_for has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def hijack_for(stdin, block, msg_stack, tty)
                                attach_block = attach_for(block, msg_stack, tty)
                            
                                lambda do |socket|
                                  debug "hijack: hijacking the HTTP socket"
                            Severity: Minor
                            Found in lib/docker/util.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 run has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def run(cmd = nil, options = {})
                                opts = {'Image' => self.id}.merge(options)
                                opts["Cmd"] = cmd.is_a?(String) ? cmd.split(/\s+/) : cmd
                                begin
                                  Docker::Container.create(opts, connection)
                            Severity: Minor
                            Found in lib/docker/image.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