matteoferla/Fragmenstein

View on GitHub
fragmenstein/monster/unmerge_mapper.py

Summary

Maintainability
D
2 days
Test Coverage

File unmerge_mapper.py has 393 lines of code (exceeds 250 allowed). Consider refactoring.
Open

########################################################################################################################

__doc__ = \
    """
Unmerge mapper (not inherited) but inherits `positional_mapping.GPM`
Severity: Minor
Found in fragmenstein/monster/unmerge_mapper.py - About 5 hrs to fix

    Function get_possible_map has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_possible_map(self,
                             other: Chem.Mol,
                             label: str,
                             o_map: Dict[int, int],  # followup -> other
                             inter_map: Dict[int, int],  # other -> combined
    Severity: Minor
    Found in fragmenstein/monster/unmerge_mapper.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 calculate has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def calculate(self, accounted_for: set):
            """perform the calculations"""
    
            #  ---- sorters  --------------------
            goodness_sorter = self.goodness_sorter_factory(3)
    Severity: Minor
    Found in fragmenstein/monster/unmerge_mapper.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 check_possible_distances has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def check_possible_distances(self, other, possible_map, combined, combined_map, cutoff=2.5):
            for i, offset_o in possible_map.items():
                unoffset_o = offset_o - combined.GetNumAtoms()
                atom = self.followup.GetAtomWithIdx(i)
                for neigh in atom.GetNeighbors():
    Severity: Minor
    Found in fragmenstein/monster/unmerge_mapper.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 bond has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def bond(self, idx: Optional[int] = None) -> Chem.Mol:
            """
            Add bonds. As in the verb 'to bond' ...
            """
            if idx is None:
    Severity: Minor
    Found in fragmenstein/monster/unmerge_mapper.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 make_maps has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def make_maps(cls, target: Chem.Mol, mols: List[Chem.Mol], mode: Optional[Dict[str, Any]] = None) \
                -> Dict[str, List[Dict[int, int]]]:
            """
            This is basically if someone is using this class outside of Monster
    
    
    Severity: Minor
    Found in fragmenstein/monster/unmerge_mapper.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 get_possible_map has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def get_possible_map(self,
    Severity: Major
    Found in fragmenstein/monster/unmerge_mapper.py - About 1 hr to fix

      Function judge_n_move_on has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def judge_n_move_on(self, combined, combined_map, other, possible_map, others, disregarded):
      Severity: Minor
      Found in fragmenstein/monster/unmerge_mapper.py - About 45 mins to fix

        Function check_possible_distances has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def check_possible_distances(self, other, possible_map, combined, combined_map, cutoff=2.5):
        Severity: Minor
        Found in fragmenstein/monster/unmerge_mapper.py - About 35 mins to fix

          Function unmerge_inner has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def unmerge_inner(self,
                                combined: Chem.Mol,
                                combined_map: Dict[int, int],
                                others: List[Chem.Mol],
                                disregarded: List[Chem.Mol]) -> None:
          Severity: Minor
          Found in fragmenstein/monster/unmerge_mapper.py - About 35 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 measure_map has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def measure_map(self, mol: Chem.Mol, mapping: Dict[int, int]) -> np.array:
                  """
                  Returns a vector with the distances but not of length len(mapping)
                  This used by offness to score how bad the mapping is
          
          
          Severity: Minor
          Found in fragmenstein/monster/unmerge_mapper.py - About 25 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

          There are no issues that match your filters.

          Category
          Status