localstack/localstack

View on GitHub
localstack/utils/container_utils/docker_cmd_client.py

Summary

Maintainability
F
4 days
Test Coverage

File docker_cmd_client.py has 763 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import functools
import itertools
import json
import logging
import os
Severity: Major
Found in localstack/utils/container_utils/docker_cmd_client.py - About 1 day to fix

    CmdDockerClient has 41 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class CmdDockerClient(ContainerClient):
        """
        Class for managing Docker (or Podman) containers using the command line executable.
    
        The client also supports targeting Podman engines, as Podman is almost a drop-in replacement
    Severity: Minor
    Found in localstack/utils/container_utils/docker_cmd_client.py - About 5 hrs to fix

      Function _build_run_create_cmd has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
      Open

          def _build_run_create_cmd(
              self,
              action: str,
              image_name: str,
              *,
      Severity: Minor
      Found in localstack/utils/container_utils/docker_cmd_client.py - About 4 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

      Function _build_run_create_cmd has 27 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def _build_run_create_cmd(
      Severity: Major
      Found in localstack/utils/container_utils/docker_cmd_client.py - About 3 hrs to fix

        Function push_image has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            def push_image(self, docker_image: str) -> None:
                cmd = self._docker_cmd()
                cmd += ["push", docker_image]
                LOG.debug("Pushing image with cmd: %s", cmd)
                try:
        Severity: Minor
        Found in localstack/utils/container_utils/docker_cmd_client.py - 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

        Function _build_run_create_cmd has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def _build_run_create_cmd(
                self,
                action: str,
                image_name: str,
                *,
        Severity: Minor
        Found in localstack/utils/container_utils/docker_cmd_client.py - About 1 hr to fix

          Function list_containers has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def list_containers(self, filter: Union[List[str], str, None] = None, all=True) -> List[dict]:
                  filter = [filter] if isinstance(filter, str) else filter
                  cmd = self._docker_cmd()
                  cmd.append("ps")
                  if all:
          Severity: Minor
          Found in localstack/utils/container_utils/docker_cmd_client.py - 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

          Function exec_in_container has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def exec_in_container(
          Severity: Major
          Found in localstack/utils/container_utils/docker_cmd_client.py - About 1 hr to fix

            Function _run_async_cmd has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def _run_async_cmd(
                    self, cmd: List[str], stdin: bytes, container_name: str, image_name=None
                ) -> Tuple[bytes, bytes]:
                    kwargs = {
                        "inherit_env": True,
            Severity: Minor
            Found in localstack/utils/container_utils/docker_cmd_client.py - 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

            Function inspect_image has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def inspect_image(
                    self,
                    image_name: str,
                    pull: bool = True,
                    strip_wellknown_repo_prefixes: bool = True,
            Severity: Minor
            Found in localstack/utils/container_utils/docker_cmd_client.py - 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

            Function start_container has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def start_container(
            Severity: Minor
            Found in localstack/utils/container_utils/docker_cmd_client.py - About 35 mins to fix

              Function pull_image has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def pull_image(self, docker_image: str, platform: Optional[DockerPlatform] = None) -> None:
                      cmd = self._docker_cmd()
                      cmd += ["pull", docker_image]
                      if platform:
                          cmd += ["--platform", platform]
              Severity: Minor
              Found in localstack/utils/container_utils/docker_cmd_client.py - About 35 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

              Function _inspect_object has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def _inspect_object(self, object_name_or_id: str) -> Dict[str, Union[dict, list, str]]:
                      cmd = self._docker_cmd()
                      cmd += ["inspect", "--format", "{{json .}}", object_name_or_id]
                      try:
                          cmd_result = run(cmd, print_error=False)
              Severity: Minor
              Found in localstack/utils/container_utils/docker_cmd_client.py - 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

              Function exec_in_container has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def exec_in_container(
                      self,
                      container_name_or_id: str,
                      command: Union[List[str], str],
                      interactive=False,
              Severity: Minor
              Found in localstack/utils/container_utils/docker_cmd_client.py - 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