Function do_run_cmd
has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring. Open
def do_run_cmd(self):
def convert_line(line):
line = to_str(line or "")
if self.strip_color:
# strip color codes
- 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
File run.py
has 397 lines of code (exceeds 250 allowed). Consider refactoring. Open
import io
import logging
import os
import re
import select
Function run
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
def run(
cmd: Union[str, List[str]],
print_error=True,
asynchronous=False,
stdin=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 __init__
has 14 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(
Function run_for_max_seconds
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def run_for_max_seconds(max_secs, _function, *args, **kwargs):
"""Run the given function for a maximum of `max_secs` seconds - continue running
in a background thread if the function does not finish in time."""
def _worker(*_args):
- 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 run
has 12 arguments (exceeds 4 allowed). Consider refactoring. Open
def run(
Avoid deeply nested control flow statements. Open
if self.log_listener:
self.log_listener(line, stream=instream)
if self.outfile not in [None, os.devnull]:
Avoid deeply nested control flow statements. Open
if not (line and line.strip()) and self.is_killed():
break
line = convert_line(line)
Avoid deeply nested control flow statements. Open
if self.outfile not in [None, os.devnull]:
outstream.write(line)
outstream.flush()
if self.process:
Avoid deeply nested control flow statements. Open
if line in [None, "", b""]:
break
if not (line and line.strip()) and self.is_killed():
Avoid deeply nested control flow statements. Open
if filter_line(line):
continue
if self.log_listener:
Function stop
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def stop(self, quiet=False):
if self.stopped:
return
if not self.process:
LOG.warning("No process found for command '%s'", self.cmd)
- 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 _set
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def _set(self, out, err, __out, __err):
Function run_cmd
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def run_cmd(self, params):
while True:
self.do_run_cmd()
from localstack.runtime import events
- 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"