matteoferla/Fragmenstein

View on GitHub
fragmenstein/faux_victors/mcs_monster.py

Summary

Maintainability
C
7 hrs
Test Coverage

File mcs_monster.py has 262 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import json, logging
from rdkit import Chem, Geometry
from rdkit.Chem import rdFMCS, AllChem  # noqa
from typing import Dict
from molecular_rectifier import Rectifier
Severity: Minor
Found in fragmenstein/faux_victors/mcs_monster.py - About 2 hrs to fix

    Function _add_bonds has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def _add_bonds(self):
            """
            Add bonds from aft to mod, a copy of fore.
            Called by combine().
            Will add property 'provenance' to bonds, with values 'fore' or 'aft' or 'common' or 'semicommon'.
    Severity: Minor
    Found in fragmenstein/faux_victors/mcs_monster.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 _con_embed has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def _con_embed(self, trial: int = 0) -> None:
            slimmed = Chem.RWMol(self.positioned_mol)
            keepers = []
            unkeepers = []
            for atom in slimmed.GetAtoms():
    Severity: Minor
    Found in fragmenstein/faux_victors/mcs_monster.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 _embed has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def _embed(self, trial=0, **embed_args) -> None:
            """
            At trial 0, all fore atoms are okay
            At trial 1, only fore atoms with bonds with original bonding are okay
            At trial 2, only common atoms with bonds with original bonding are okay
    Severity: Minor
    Found in fragmenstein/faux_victors/mcs_monster.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 is_valid has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def is_valid(self, atom: Chem.Atom, trial: int):
            """
            Is this a constrainable atom?
            """
            if atom.GetAtomicNum() == 1:
    Severity: Minor
    Found in fragmenstein/faux_victors/mcs_monster.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 trial == 1 or atom.GetProp('provenance') == 'common'
    Severity: Major
    Found in fragmenstein/faux_victors/mcs_monster.py - About 30 mins to fix

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

          def _clean_up(self):
              """
              `.flat_combo`` is ``.mod`` withoout Hs and coordinates.
              `.rectified`` is ``.flat_combo`` after rectification.
              the returned will be `.positioned_mol`` ie. ``.rectified`` with Hs.
      Severity: Minor
      Found in fragmenstein/faux_victors/mcs_monster.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 convert_to_origins has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def convert_to_origins(self, mol: Chem.Mol, both=False):
              """
              In this class the 'provenance' are marked as common, aft, fore, rectified (semicommon is bond)
              """
              fore_name = self.fore.GetProp('_Name')
      Severity: Minor
      Found in fragmenstein/faux_victors/mcs_monster.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 _add_atoms has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def _add_atoms(self):
              """
              Add atoms from aft to mod, a copy of fore.
              Called by combine().
              Will add property 'provenance' to atoms, with values 'fore', 'aft' or 'common'.
      Severity: Minor
      Found in fragmenstein/faux_victors/mcs_monster.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