swipely/docker-api

View on GitHub
lib/docker/util.rb

Summary

Maintainability
B
4 hrs
Test Coverage

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

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

      There are no issues that match your filters.

      Category
      Status