matteoferla/Fragmenstein

View on GitHub
fragmenstein/monster/_place_modes/_no_blending.py

Summary

Maintainability
B
5 hrs
Test Coverage

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:
Severity: Minor
Found in fragmenstein/monster/_place_modes/_no_blending.py - About 2 hrs to fix

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

Severity: Minor
Found in fragmenstein/monster/_place_modes/_no_blending.py - About 55 mins to fix

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:
        """
Severity: Minor
Found in fragmenstein/monster/_place_modes/_no_blending.py - About 45 mins to fix

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):
Severity: Major
Found in fragmenstein/monster/_place_modes/_no_blending.py - About 40 mins to fix

    Avoid too many return statements within this function.
    Open

                return {k: self._remove_negatives(v) for k, v in map.items()}
    Severity: Major
    Found in fragmenstein/monster/_place_modes/_no_blending.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                  return {h: f for h, f in map.items() if f >= 0 and h >= 0}
      Severity: Major
      Found in fragmenstein/monster/_place_modes/_no_blending.py - About 30 mins to fix

        There are no issues that match your filters.

        Category
        Status