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
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
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,
*,
- Read upRead up
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(
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:
- Read upRead up
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,
*,
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:
- Read upRead up
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(
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,
- Read upRead up
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,
- Read upRead up
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(
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]
- Read upRead up
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)
- Read upRead up
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,
- Read upRead up
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"