matteoferla/Fragmenstein

View on GitHub
fragmenstein/monster/_communal.py

Summary

Maintainability
D
2 days
Test Coverage

File _communal.py has 379 lines of code (exceeds 250 allowed). Consider refactoring.
Open

########################################################################################################################
__doc__ = \
    """
This is inherited by all three parents of the place/combine/other group
    """
Severity: Minor
Found in fragmenstein/monster/_communal.py - About 5 hrs to fix

    _MonsterCommunal has 22 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class _MonsterCommunal(_MonsterTracker):
    
        # === Find closest =================================================================================================
        # dep methods:
    
    
    Severity: Minor
    Found in fragmenstein/monster/_communal.py - About 2 hrs to fix

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

          def _is_connected_warhead(self, atom, anchor_atom):
              if not atom.HasProp('_Warhead'):
                  return False
              elif atom.GetBoolProp('_Warhead') == False:
                  return False
      Severity: Minor
      Found in fragmenstein/monster/_communal.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 _add_bond_if_possible has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def _add_bond_if_possible(self, mol, first: Chem.Atom, second: Chem.Atom, provenance='other_novel'):
              """
              This method is used by _copy_bonding, but triggered when force=False
      
              :param mol:
      Severity: Minor
      Found in fragmenstein/monster/_communal.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 _copy_bonding has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def _copy_bonding(self, mol, keeper_idx: int, reject_idx: int, force: Optional[bool] = None):
              """
              formerly called `absorb`. Preps for absorbing. remove reject_idx separately.
              So copy bonding from reject_idx to keeper_idx.
      
      
      Severity: Minor
      Found in fragmenstein/monster/_communal.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 _add_bond_regardlessly has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def _add_bond_regardlessly(self, mol, first: Chem.Atom, second: Chem.Atom, bond_type, provenance='other_novel'):
      Severity: Minor
      Found in fragmenstein/monster/_communal.py - About 35 mins to fix

        Avoid too many return statements within this function.
        Open

                    return False
        Severity: Major
        Found in fragmenstein/monster/_communal.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return False
          Severity: Major
          Found in fragmenstein/monster/_communal.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                        return False  # too bonded etc.
            Severity: Major
            Found in fragmenstein/monster/_communal.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return True
              Severity: Major
              Found in fragmenstein/monster/_communal.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                            return False
                Severity: Major
                Found in fragmenstein/monster/_communal.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                              return False  # too bonded already!
                  Severity: Major
                  Found in fragmenstein/monster/_communal.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                            return False  # if the warhead is not connected pretend it is not a warhead.
                    Severity: Major
                    Found in fragmenstein/monster/_communal.py - About 30 mins to fix

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

                          def _closest__is_ring_atom(atom):
                              if atom.GetIsAromatic():
                                  return True
                              elif atom.HasProp('_ori_i') and atom.GetIntProp('_ori_i') == -1:
                                  if atom.HasProp('_bonds') and 'AROMATIC' in atom.GetProp('_bonds'):
                      Severity: Minor
                      Found in fragmenstein/monster/_communal.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