Function get_local_var_names_from_funcdef
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def get_local_var_names_from_funcdef(funcdef_node: AnyFuncdef) -> List[str]:
local_vars_names: List[str] = []
for assign_node in get_nodes_from_funcdef_body(funcdef_node, [ast.Assign]):
for target in assign_node.targets:
local_vars_names += [n.id for n in ast.walk(target) if isinstance(n, ast.Name)]
- 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_global_import_nodes
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_all_global_import_nodes(file_ast_tree: ast.AST) -> List[Union[ast.ImportFrom, ast.Import]]:
nodes_with_local_scope = {ast.FunctionDef, ast.AsyncFunctionDef, ast.ClassDef}
import_nodes: List[Union[ast.ImportFrom, ast.Import]] = []
for node in getattr(file_ast_tree, 'body', []):
- 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 is_imported_from_stdlib
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def is_imported_from_stdlib(name: str, file_ast_tree: ast.Module) -> Optional[bool]:
for import_node in get_all_global_import_nodes(file_ast_tree):
for full_import_path in get_full_import_pathes(import_node):
if full_import_path.split('.')[-1] == name:
base_module = full_import_path.split('.')[0]
- 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"