Function keys_to
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def keys_to(
obj: ComplexType, op: Callable[[str], str], skip_children_of: List[str] = None
) -> ComplexType:
"""Recursively changes all dict keys to apply op. Skip children
of any elements whose names are contained in skip_children_of (e.g., ['Tags'])"""
- 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 recurse_object
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def recurse_object(obj: ComplexType, func: Callable, path: str = "") -> ComplexType:
"""Recursively apply `func` to `obj` (might be a list, dict, or other object)."""
obj = func(obj, path=path)
if isinstance(obj, list):
for i in range(len(obj)):
- 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
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def get(cls, subtype_name: str, raise_if_missing: bool = True):
instances = cls.instances()
base_type = cls.get_base_type()
instance = instances.get(subtype_name)
if instance is None:
- 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"