matteoferla/Fragmenstein

View on GitHub
fragmenstein/m_rmsd.py

Summary

Maintainability
D
2 days
Test Coverage

File m_rmsd.py has 437 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from __future__ import annotations
from collections import defaultdict
########################################################################################################################

__doc__ = \
Severity: Minor
Found in fragmenstein/m_rmsd.py - About 6 hrs to fix

    Function from_other_annotated_mols has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

        def from_other_annotated_mols(cls,
                                followup: Chem.Mol,
                                hits: Sequence[Chem.Mol],
                                annotated: Chem.Mol,
                                ) -> mRMSD:
    Severity: Minor
    Found in fragmenstein/m_rmsd.py - About 4 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

    mRMSD has 21 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class mRMSD:
        """Mols are non-superposed ('aligned') for the RMSD and in Å.
    
        The RMSD has been calculated differently.
        The inbuilt RMSD calculations in RDKit (``Chem.rdMolAlign.GetBestRMS``) align the two molecules,
    Severity: Minor
    Found in fragmenstein/m_rmsd.py - About 2 hrs to fix

      Function _mapping_from_annotated_and_hits has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def _mapping_from_annotated_and_hits(cls,
                                               annotated_followup: Chem.Mol,
                                               hits: Sequence[Chem.Mol]):
              assert cls.is_origin_annotated(annotated_followup), 'This molecules is not annotated.'
              mappings = []
      Severity: Minor
      Found in fragmenstein/m_rmsd.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 overannotate has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def overannotate(cls, mol: Chem.Mol, hits: List[Chem.Mol], priority=('mol_origin', 'atom_origin', 'xyz')):
              """
              Unfortunately, in an attempt to make users happy, I have to make the code more complicated.
              There are three different annotation systems going on.
              The first is the property '_Origin' in the ``Chem.Mol``.
      Severity: Minor
      Found in fragmenstein/m_rmsd.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 copy_all_possible_origins has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def copy_all_possible_origins(cls, annotated: Chem.Mol, target: Chem.Mol) -> Tuple[List[Chem.Mol], List[List[int]]]:
              """
              Monster leaves a note of what it did. atom prop _Origin is a json of a list of mol _Name dot AtomIdx.
              However, the atom order seems to be maintained but I dont trust it. Also dummy atoms are stripped.
      
      
      Severity: Minor
      Found in fragmenstein/m_rmsd.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 from_internal_xyz has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def from_internal_xyz(cls, annotated_followup):
              """
              This is an alternative for when the atoms have _x, _y, _z
              
              :param annotated_followup:
      Severity: Minor
      Found in fragmenstein/m_rmsd.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

      Avoid deeply nested control flow statements.
      Open

                              if rex is not None:
                                  h = int(rex.group(1))
                                  mapping.append((i, h))
                  mappings.append(mapping)
      Severity: Major
      Found in fragmenstein/m_rmsd.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if xyz:
                                    cls._set_xyz(tatom, xyz)
                        options.append(option)
        Severity: Major
        Found in fragmenstein/m_rmsd.py - About 45 mins to fix

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

              def _atom_origin_to_xyz(cls, origins: List[str], atom: Chem.Atom, hits: List[Chem.Mol]):
                  points = []
                  if len(hits) == 0:
                      return  # no hits
                  hitdex: Dict[str, Chem.Mol] = {hit.GetProp('_Name'): hit for hit in hits}
          Severity: Minor
          Found in fragmenstein/m_rmsd.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

          Avoid too many return statements within this function.
          Open

                      return None
          Severity: Major
          Found in fragmenstein/m_rmsd.py - About 30 mins to fix

            Function __init__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def __init__(self,
                             followup: Chem.Mol,
                             hits: Sequence[Chem.Mol],
                             mappings: List[List[Tuple[int, int]]]):
                    """
            Severity: Minor
            Found in fragmenstein/m_rmsd.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