Function _remove_poisonous
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def _remove_poisonous(self,
flipped_maps,
poisonous_indices: List[int],
n_poisonous: int,
primary_name:Optional[str]=None) -> 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"
Further reading
Function _remove_negatives
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def _remove_negatives(self, map: Any) -> Any:
"""
This is a hack to remove negative values from the map.
It like flip_mapping is a tangle of options. The latter has been typing.overload'ed
- 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 _perform_unmerge
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _perform_unmerge(self,
maps: Dict[str, List[Dict[int, int]]],
n_poisonous:int,
primary_name:Optional[str]=None) -> Unmerge:
"""
- 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
Consider simplifying this complex logical expression. Open
if isinstance(map, list) and isinstance(map[0], tuple) and isinstance(map[0][0], tuple):
return [(h, f) for h, f in map if f >= 0 and h >= 0]
elif isinstance(map, list) and isinstance(map[0], list):
return [self._remove_negatives(m) for m in map]
elif isinstance(map, list) and isinstance(map[0], dict):
Avoid too many return
statements within this function. Open
return {k: self._remove_negatives(v) for k, v in map.items()}
Avoid too many return
statements within this function. Open
return {h: f for h, f in map.items() if f >= 0 and h >= 0}