matteoferla/Fragmenstein

View on GitHub
fragmenstein/victor/_victor_common.py

Summary

Maintainability
D
2 days
Test Coverage

Function harmonize_warheads has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

    def harmonize_warheads(self, hits, warhead_harmonisation, covalent_form=True):
        """
        Harmonises and marks the atoms with `_Warhead` Prop.

        :param hits:
Severity: Minor
Found in fragmenstein/victor/_victor_common.py - About 5 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

File _victor_common.py has 358 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from ._victor_igor import _VictorIgor
from .minimalPDB import MinimalPDBParser
import os, re
from typing import *
from rdkit import Chem
Severity: Minor
Found in fragmenstein/victor/_victor_common.py - About 4 hrs to fix

    Function make_coordinate_constraints_for_placement has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        def make_coordinate_constraints_for_placement(self,
                                        mol: Optional[Chem.Mol] = None,
                                        origins: Optional[List[List[str]]] = None,
                                        std: Optional[List[float]] = None,
                                        mx: Optional[List[float]] = None) -> str:
    Severity: Minor
    Found in fragmenstein/victor/_victor_common.py - About 3 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 _get_attachment_from_pdbblock_via_pymol has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def _get_attachment_from_pdbblock_via_pymol(self) -> Union[None, Chem.Mol]:
            """
            DEPRACATED. FORMER CODE FOR ``_get_attachment_from_pdbblock``
    
            Yes, yes, I see the madness in using pymol to get an atom for rdkit to make a pose for pyrosetta.
    Severity: Minor
    Found in fragmenstein/victor/_victor_common.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_attachment_from_pdbblock has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def _get_attachment_from_pdbblock(self) -> Union[None, Chem.Mol]:
            """
            ``find_attachment`` finds the actual attachment atom not the stated one.
            The historic code for this is now ``_get_attachment_from_pdbblock_via_pymol``
            :return:
    Severity: Minor
    Found in fragmenstein/victor/_victor_common.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_coordinate_constraints_for_combination has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def make_coordinate_constraints_for_combination(self):
            """
            See also ``cls.make_coordinate_constraints_for_placement``.
            This operates based on ``atom.HasProp('_Novel')``, not origins!
            :return:
    Severity: Minor
    Found in fragmenstein/victor/_victor_common.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 first is None:
                                first = warhead_name
                                new_hits.append(hit)
                            elif warhead_name == first:
                                new_hits.append(hit)
    Severity: Major
    Found in fragmenstein/victor/_victor_common.py - About 45 mins to fix

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

          def _get_war_def(self):
              for war_def in self.warhead_definitions:
                  warhead = Chem.MolFromSmiles(war_def['covalent'])
                  if self.mol.HasSubstructMatch(warhead):
                      return war_def
      Severity: Minor
      Found in fragmenstein/victor/_victor_common.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 inventorize_warheads has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def inventorize_warheads(cls, hits: List[Chem.Mol], covalent_form: bool = True) -> List[str]:
              """
              Get the warhead types of the list of hits
      
              :param hits:
      Severity: Minor
      Found in fragmenstein/victor/_victor_common.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

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

          def _get_constraint(self, extra_constraint: Optional[str] = None) -> Union[Constraints, None]:
              # deal with covalent and non covalent separately
              if self.is_covalent:
                  self.journal.debug(f'{self.long_name} - is covalent.')
                  constraint = self._fix_covalent()
      Severity: Minor
      Found in fragmenstein/victor/_victor_common.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