fragmenstein/monster/mcs_mapping/utils.py
Function flip_mapping
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
Open
def flip_mapping(mapping):
"""
This is a temporary fix for the fact that many route run on mappings that go hit to followup or viceversa
Moving forward these will be replaced with a single hit to followup scheme, of type IndexMap
"""
- 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 transmute_FindMCS_parameters
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def transmute_FindMCS_parameters(
**mode: Unpack[ExtendedFMCSMode]) -> rdFMCS.MCSParameters: # noqa lowercase not applicable
"""
The function ``rdFMCS.FindMCS`` has two ways of being used.
In one, a series of arguments are passed,
Consider simplifying this complex logical expression. Open
Open
if len(mapping) == 0:
return mapping
# Sequence[Tuple[int, int]] (basic)
elif isinstance(mapping, Sequence) and isinstance(mapping[0], tuple) and isinstance(mapping[0][1], int):
return [(b, a) for a, b in mapping]
Avoid too many return
statements within this function. Open
Open
return {name: flip_mapping(submapping) for name, submapping in mapping.items()}
Avoid too many return
statements within this function. Open
Open
return {name: flip_mapping(submapping) for name, submapping in mapping.items()}