Showing 46 of 50 total issues
Cyclomatic complexity is too high in method compile_object. (6) Open
def compile_object(self) -> None:
glob_so = str(self.app_name) + ".*.so"
opt = "-q" if not self.args.verbose else ""
setup_py = str(Path(self.root) / "setup.py")
setup_runner = f"{sys.executable} {setup_py} {opt} build_ext -b ."
- Read upRead up
- Exclude checks
Cyclomatic Complexity
Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.
Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:
Construct | Effect on CC | Reasoning |
---|---|---|
if | +1 | An if statement is a single decision. |
elif | +1 | The elif statement adds another decision. |
else | +0 | The else statement does not cause a new decision. The decision is at the if. |
for | +1 | There is a decision at the start of the loop. |
while | +1 | There is a decision at the while statement. |
except | +1 | Each except branch adds a new conditional path of execution. |
finally | +0 | The finally block is unconditionally executed. |
with | +1 | The with statement roughly corresponds to a try/except block (see PEP 343 for details). |
assert | +1 | The assert statement internally roughly equals a conditional statement. |
Comprehension | +1 | A list/set/dict comprehension of generator expression is equivalent to a for loop. |
Boolean Operator | +1 | Every boolean operator (and, or) adds a decision point. |
Cyclomatic complexity is too high in method handle_names. (6) Open
def handle_names(self):
prevname = ""
for name in self.names:
if name[:3] == "do_":
if name == prevname:
- Read upRead up
- Exclude checks
Cyclomatic Complexity
Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.
Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:
Construct | Effect on CC | Reasoning |
---|---|---|
if | +1 | An if statement is a single decision. |
elif | +1 | The elif statement adds another decision. |
else | +0 | The else statement does not cause a new decision. The decision is at the if. |
for | +1 | There is a decision at the start of the loop. |
while | +1 | There is a decision at the while statement. |
except | +1 | Each except branch adds a new conditional path of execution. |
finally | +0 | The finally block is unconditionally executed. |
with | +1 | The with statement roughly corresponds to a try/except block (see PEP 343 for details). |
assert | +1 | The assert statement internally roughly equals a conditional statement. |
Comprehension | +1 | A list/set/dict comprehension of generator expression is equivalent to a for loop. |
Boolean Operator | +1 | Every boolean operator (and, or) adds a decision point. |
Function cvt_arith_expr
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def cvt_arith_expr(s, loc, t):
expr = "".join((str(i) for i in t))
substr = ["!", "**", "//", "/", "%", '*' '-', '+']
handler = {
lambda x: "!" in x: factorial,
- 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 input
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def input(self):
self.stdout.flush()
line = input(START_PROMPT)
if "))" in line and line.endswith(tuple(Extension.registrar.keys()) + ("*",)):
- 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 __exit__
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def __exit__(self, exc_type, exc_val, exc_tb):
self.part_file.close()
if exc_type:
if self.rm_part_on_exc:
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 handle_names
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def handle_names(self):
prevname = ""
for name in self.names:
if name[:3] == "do_":
if name == prevname:
- 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 SafeExp
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def SafeExp(a, b):
if (
(a == 0 and b == 0) or (isinf(a) and b == 0) or (isinf(b) and a == 0)
): # pragma: no cover
return Undefined(SafeExp, a, b)
- 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 replace
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def replace(src, dst):
# argument names match stdlib docs, docstring below
try:
# ReplaceFile fails if the dest file does not exist, so
# first try to rename it into position
- 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 maybe_call
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def maybe_call(instance, func, args, kwargs, _warn, warn_undefined):
Consider simplifying this complex logical expression. Open
if (
(a == 0 and b == 0) or (isinf(a) and b == 0) or (isinf(b) and a == 0)
): # pragma: no cover
return Undefined(SafeExp, a, b)
try:
Function _wrap_lines
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def _wrap_lines(text, padchar, width, wrapped_lines, pad):
Function __init__
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self, compile_args: CompilerArgs):
self.args = compile_args
self.file_stack = CheckedFileStack()
self.fname = Path(self.args.fname)
if str(self.fname).endswith(".py"):
- 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 maybe_call
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def maybe_call(instance, func, args, kwargs, _warn, warn_undefined):
e: Exception
w: str
warn_undefined: bool
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 get_all
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_all(type_obj, include_subtypes=True):
"""Get a list containing all instances of a given type. This will
work for the vast majority of types out there.
>>> RatKing = type('Ratking', {})
- 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 setup_test_env
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def setup_test_env(argv):
if len(argv) >= 2 and argv[1] == "--pytest" or argv[1] == "-pt": # pragma: no cover
if not os.getenv("ASPIDITES_DOCKER_BUILD"):
argv = [
str(Path(__file__).absolute().parent / Path("tests/test_aspidites.py"))
- 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
Try, Except, Pass detected. Open
except Exception:
- Exclude checks
Starting a process with a shell, possible injection detected, security issue. Open
os.system("cls" if os.name == "nt" else "clear")
- Exclude checks
The input method in Python 2 will read from standard input, evaluate and run the resulting string as python source code. This is similar, though in many ways worse, then using eval. On Python 2, use raw_input instead, input is safe in Python 3. Open
line = input(START_PROMPT)
- Exclude checks
Consider possible security implications associated with pickle module. Open
import pickle
- Exclude checks
Use of possibly insecure function - consider using safer ast.literal_eval. Open
out = eval(
compile(x, filename="<inline code>", mode="eval"),
self.__locals__,
self.__locals__,
- Exclude checks