matteoferla/Fragmenstein

View on GitHub
fragmenstein/monster/mcs_mapping/utils.py

Summary

Maintainability
B
4 hrs
Test Coverage

Function flip_mapping has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
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
    """
Severity: Minor
Found in fragmenstein/monster/mcs_mapping/utils.py - About 1 hr 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 transmute_FindMCS_parameters has 27 lines of code (exceeds 25 allowed). Consider refactoring.
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,
Severity: Minor
Found in fragmenstein/monster/mcs_mapping/utils.py - About 1 hr to fix

    Consider simplifying this complex logical expression.
    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]
    Severity: Major
    Found in fragmenstein/monster/mcs_mapping/utils.py - About 1 hr to fix

      Avoid too many return statements within this function.
      Open

              return {name: flip_mapping(submapping) for name, submapping in mapping.items()}
      Severity: Major
      Found in fragmenstein/monster/mcs_mapping/utils.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return {name: flip_mapping(submapping) for name, submapping in mapping.items()}
        Severity: Major
        Found in fragmenstein/monster/mcs_mapping/utils.py - About 30 mins to fix

          There are no issues that match your filters.

          Category
          Status