KarrLab/bpforms

View on GitHub
bpforms/core.py

Summary

Maintainability
F
1 mo
Test Coverage
A
99%

File core.py has 3761 lines of code (exceeds 250 allowed). Consider refactoring.
Open

""" Classes to represent modified forms of DNA, RNA, and proteins

:Author: Jonathan Karr <karr@mssm.edu>
:Date: 2019-01-31
:Copyright: 2019, Karr Lab
Severity: Major
Found in bpforms/core.py - About 1 wk to fix

    Function validate has a Cognitive Complexity of 113 (exceeds 5 allowed). Consider refactoring.
    Open

        def validate(self):
            """ Check that the biopolymer form is valid and return any errors
    
            * Check that monomeric forms :math:`1 \ldots L-1` can bond to the right (their right bonding attributes are set)
            * Check that monomeric forms :math:`2 \ldots L` can bond to the left (their left bonding attributes are set)
    Severity: Minor
    Found in bpforms/core.py - About 2 days 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_str has a Cognitive Complexity of 102 (exceeds 5 allowed). Consider refactoring.
    Open

        def from_str(self, string):
            """ Create biopolymer form its string representation
    
            Args:
                string (:obj:`str`): string representation of the biopolymer
    Severity: Minor
    Found in bpforms/core.py - About 2 days 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_structure has a Cognitive Complexity of 84 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_structure(self, include_all_hydrogens=False):
            """ Get an Open Babel molecule of the structure
    
            Args:
                include_all_hydrogens (:obj:`bool`, optional): if :obj:`True`, explicitly include all
    Severity: Minor
    Found in bpforms/core.py - About 1 day 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 diff has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
    Open

        def diff(self, other):
            """ Determine the semantic difference between two biopolymer forms
    
            Args:
                other (:obj:`BpForm`): another biopolymer form
    Severity: Minor
    Found in bpforms/core.py - About 1 day 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

    Monomer has 51 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Monomer(object):
        """ A monomeric form in a biopolymer
    
        Attributes:
            id (:obj:`str`): id
    Severity: Major
    Found in bpforms/core.py - About 7 hrs to fix

      BpForm has 45 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class BpForm(object):
          """ Biopolymer form
      
          Attributes:
              seq (:obj:`MonomerSequence`): sequence of monomeric forms of the biopolymer
      Severity: Minor
      Found in bpforms/core.py - About 6 hrs to fix

        Bond has 33 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Bond(BondBase):
            """ Bond between monomeric forms (inter-residue bond or crosslink)
        
            Attributes:
                id (:obj:`str`): id
        Severity: Minor
        Found in bpforms/core.py - About 4 hrs to fix

          Function get_charge has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
          Open

              def get_charge(self):
                  """ Get the charge
          
                  Returns:
                      :obj:`int`: charge
          Severity: Minor
          Found in bpforms/core.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 form has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
          Open

              def form(self, value):
                  """ Set the biopolymer form
          
                  Args:
                      value (:obj:`BpForm`): biopolymer form
          Severity: Minor
          Found in bpforms/core.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_formula has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
          Open

              def get_formula(self):
                  """ Get the chemical formula
          
                  Returns:
                      :obj:`EmpiricalFormula`: chemical formula
          Severity: Minor
          Found in bpforms/core.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 __str__ has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

              def __str__(self, alphabet=None):
                  """ Get a string representation of the monomeric form
          
                  Args:
                      alphabet (:obj:`Alphabet`, optional): alphabet
          Severity: Minor
          Found in bpforms/core.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 is_equal has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

              def is_equal(self, other):
                  """ Check if two monomeric forms are semantically equal
          
                  Args:
                      other (:obj:`Monomer`): another monomeric form
          Severity: Minor
          Found in bpforms/core.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 to_dict has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

              def to_dict(self, alphabet=None):
                  """ Get a dictionary representation of the monomeric form
          
                  Args:
                      alphabet (:obj:`Alphabet`, optional): alphabet
          Severity: Minor
          Found in bpforms/core.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 _bond_monomer_backbone has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

              def _bond_monomer_backbone(self, mol, subunit_atoms, atom_map):
                  """ Bond a monomeric form to a backbone
          
                  Args:
                      mol (:obj:`openbabel.OBMol`): molecule with a monomeric form and backbone
          Severity: Minor
          Found in bpforms/core.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 _bond_subunits has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              def _bond_subunits(self, mol, left_atoms, right_atoms, atom_map):
                  """  Bond a left/right pair of subunits
          
                  Args:
                      mol (:obj:`openbabel.OBMol`): molecule with left and right subunits
          Severity: Minor
          Found in bpforms/core.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 __init__ has 18 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def __init__(self, id=None, name=None, synonyms=None, identifiers=None, structure=None,
          Severity: Major
          Found in bpforms/core.py - About 2 hrs to fix

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

                def get_image(self, bond_label='', displaced_label='', bond_opacity=255, displaced_opacity=63,
                              backbone_bond_color=0xff0000, left_bond_color=0x00ff00, right_bond_color=0x0000ff,
                              include_all_hydrogens=True, show_atom_nums=False,
                              atom_label_font_size=0.6,
                              width=200, height=200, image_format='svg', include_xml_header=True):
            Severity: Minor
            Found in bpforms/core.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 is_equal has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                def is_equal(self, other):
                    """ Determine if two bonds are semantically equal
            
                    Args:
                        other (:obj:`Bond`): other bond
            Severity: Minor
            Found in bpforms/core.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_image has 14 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def get_image(self, bond_label='', displaced_label='', bond_opacity=255, displaced_opacity=63,
            Severity: Major
            Found in bpforms/core.py - About 1 hr to fix

              Function _form_crosslink has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                  def _form_crosslink(self, mol, atoms, atom_map, order, stereo):
                      """ Form bond(s) for a crosslink
              
                      Args:
                          mol (:obj:`openbabel.OBMol`): molecule
              Severity: Minor
              Found in bpforms/core.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 __init__ has 12 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def __init__(self, id=None, name=None, synonyms=None,
              Severity: Major
              Found in bpforms/core.py - About 1 hr to fix

                Function get_image has 12 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def get_image(self, monomer_color=0x000000, backbone_color=0xff0000,
                Severity: Major
                Found in bpforms/core.py - About 1 hr to fix

                  Function get_image has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def get_image(self, monomer_color=0x000000, backbone_color=0xff0000,
                                    left_right_bond_color=0x00ff00, crosslink_bond_color=0x0000ff,
                                    include_all_hydrogens=True, show_atom_nums=False,
                                    atom_label_font_size=0.6,
                                    width=200, height=200, image_format='svg', include_xml_header=True):
                  Severity: Minor
                  Found in bpforms/core.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 __str__ has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def __str__(self):
                          """ Get a string representation of the biopolymer form
                  
                          Returns:
                              :obj:`str`: string representation of the biopolymer form
                  Severity: Minor
                  Found in bpforms/core.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_charge has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def get_charge(self, none_position=True):
                          """ Get the charge
                  
                          Args:
                              none_position (:obj:`bool`, optional): include atoms whose position is :obj:`None`
                  Severity: Minor
                  Found in bpforms/core.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 is_equal has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def is_equal(self, other):
                          """ Check if two sets of nicks are semantically equal
                  
                          Args:
                              other (:obj:`NickSet`): other set of nicks
                  Severity: Minor
                  Found in bpforms/core.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 __str__ has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def __str__(self):
                          """ Generate string representation of bond
                  
                          Returns:
                              :obj:`str`: string representation of bond
                  Severity: Minor
                  Found in bpforms/core.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 is_equal has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def is_equal(self, other):
                          """ Check if two sets of bonds are semantically equal
                  
                          Args:
                              other (:obj:`BondSet`): other set of bonds
                  Severity: Minor
                  Found in bpforms/core.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_bonds_to_set has 9 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def _add_bonds_to_set(self, mol, r_bond_atoms, l_bond_atoms, atom_map, bond_set, el_table,
                  Severity: Major
                  Found in bpforms/core.py - About 1 hr to fix

                    Function from_dict has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def from_dict(self, dict, alphabet=None):
                            """ Get a dictionary representation of the monomeric form
                    
                            Args:
                                dict (:obj:`dict`): dictionary representation of the monomeric form
                    Severity: Minor
                    Found in bpforms/core.py - About 1 hr to fix

                      Function check_atom has 8 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                              def check_atom(molecule, atom_type, i_monomer, i_atom, structure, atom_md, bonding_hydrogens, el_table, errors):
                      Severity: Major
                      Found in bpforms/core.py - About 1 hr to fix

                        Function __setitem__ has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def __setitem__(self, slice, monomer):
                                """ Set monomeric form(s) at slice
                        
                                Args:
                                    slice (:obj:`int` or :obj:`slice`): position(s) to set monomeric form
                        Severity: Minor
                        Found in bpforms/core.py - About 55 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 __setitem__ has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def __setitem__(self, slice, atom):
                                """ Set atom(s) at slice
                        
                                Args:
                                    slice (:obj:`int` or :obj:`slice`): position(s) to set atom
                        Severity: Minor
                        Found in bpforms/core.py - About 55 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_equal has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def is_equal(self, other):
                                """ Determine two alphabets are semantically equal
                        
                                Args:
                                    other (:obj:`type`): other alphabet
                        Severity: Minor
                        Found in bpforms/core.py - About 55 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 from_dict has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def from_dict(self, dict, alphabet=None):
                                """ Get a dictionary representation of the monomeric form
                        
                                Args:
                                    dict (:obj:`dict`): dictionary representation of the monomeric form
                        Severity: Minor
                        Found in bpforms/core.py - About 55 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 __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            def __init__(self, seq=None, alphabet=None, backbone=None, bond=None, circular=False,
                        Severity: Major
                        Found in bpforms/core.py - About 50 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                  if atom_md.molecule == Monomer:
                                                      atom = mol.GetAtom(n_atom + atom_md.position)
                                                  else:
                                                      atom = mol.GetAtom(n_atom + atom_md.position + monomer_structure.NumAtoms())
                                                  subunit_atoms[type][attr[0]].append([atom, atom_md.molecule, atom_md.position, atom_md.element, atom_md.charge])
                          Severity: Major
                          Found in bpforms/core.py - About 45 mins to fix

                            Function is_equal has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def is_equal(self, other):
                                    """ Determine if two bonds are semantically equal
                            
                                    Args:
                                        other (:obj:`Bond`): other bond
                            Severity: Minor
                            Found in bpforms/core.py - About 45 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 deeply nested control flow statements.
                            Open

                                                    if atom_el[-2] == 'H':
                                                        type_atoms[i_atom_el] = (
                                                            get_hydrogen_atom(atom_el[0], bonding_hydrogens, i_monomer),
                                                            i_monomer + 1, atom_el[1], atom_el[2], atom_el[4])
                                                    else:
                            Severity: Major
                            Found in bpforms/core.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                      if atom.molecule != Monomer or not atom.monomer or not atom.element or not atom.position:
                                                          errors.append("'{}[{}]' of crosslink {} must have a defined monomer, element, and position".format(
                                                              atom_type, i_atom, i_crosslink + 1))
                                                      else:
                                                          check_atom('Crosslink {} - monomer {}'.format(i_crosslink, atom.monomer), atom_type, atom.monomer - 1, i_atom,
                              Severity: Major
                              Found in bpforms/core.py - About 45 mins to fix

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

                                    def _form_crosslink(self, mol, atoms, atom_map, order, stereo):
                                Severity: Minor
                                Found in bpforms/core.py - About 35 mins to fix

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

                                      def __init__(self, molecule, element, position=None, charge=0, monomer=None):
                                  Severity: Minor
                                  Found in bpforms/core.py - About 35 mins to fix

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

                                        def _add_bonds_to_set(self, mol, r_bond_atoms, l_bond_atoms, atom_map, bond_set, el_table,
                                                              i_monomer_1=None, i_monomer_2=None):
                                            for md_atom_1, md_atom_2 in zip(r_bond_atoms, l_bond_atoms):
                                                if i_monomer_1 is None:
                                                    i_monomer_1 = md_atom_1.monomer
                                    Severity: Minor
                                    Found in bpforms/core.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 False
                                    Severity: Major
                                    Found in bpforms/core.py - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                              return True
                                      Severity: Major
                                      Found in bpforms/core.py - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

                                                return True
                                        Severity: Major
                                        Found in bpforms/core.py - About 30 mins to fix

                                          Avoid too many return statements within this function.
                                          Open

                                                          return False
                                          Severity: Major
                                          Found in bpforms/core.py - About 30 mins to fix

                                            Avoid too many return statements within this function.
                                            Open

                                                                return False
                                            Severity: Major
                                            Found in bpforms/core.py - About 30 mins to fix

                                              Avoid too many return statements within this function.
                                              Open

                                                          return False
                                              Severity: Major
                                              Found in bpforms/core.py - About 30 mins to fix

                                                Avoid too many return statements within this function.
                                                Open

                                                            return False
                                                Severity: Major
                                                Found in bpforms/core.py - About 30 mins to fix

                                                  Avoid too many return statements within this function.
                                                  Open

                                                          return True
                                                  Severity: Major
                                                  Found in bpforms/core.py - About 30 mins to fix

                                                    Avoid too many return statements within this function.
                                                    Open

                                                                return False
                                                    Severity: Major
                                                    Found in bpforms/core.py - About 30 mins to fix

                                                      Avoid too many return statements within this function.
                                                      Open

                                                                  return False
                                                      Severity: Major
                                                      Found in bpforms/core.py - About 30 mins to fix

                                                        Avoid too many return statements within this function.
                                                        Open

                                                                return True
                                                        Severity: Major
                                                        Found in bpforms/core.py - About 30 mins to fix

                                                          Avoid too many return statements within this function.
                                                          Open

                                                                  return True
                                                          Severity: Major
                                                          Found in bpforms/core.py - About 30 mins to fix

                                                            Avoid too many return statements within this function.
                                                            Open

                                                                    return True
                                                            Severity: Major
                                                            Found in bpforms/core.py - About 30 mins to fix

                                                              Avoid too many return statements within this function.
                                                              Open

                                                                              return False
                                                              Severity: Major
                                                              Found in bpforms/core.py - About 30 mins to fix

                                                                Avoid too many return statements within this function.
                                                                Open

                                                                        return True
                                                                Severity: Major
                                                                Found in bpforms/core.py - About 30 mins to fix

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

                                                                      def is_equal(self, other):
                                                                          """ Determine if two lists of atoms are semantically equal
                                                                  
                                                                          Args:
                                                                              other (:obj:`AtomList`): other list of atoms
                                                                  Severity: Minor
                                                                  Found in bpforms/core.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_formula has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                  Open

                                                                      def get_formula(self, none_position=True):
                                                                          """ Get the formula
                                                                  
                                                                          Args:
                                                                              none_position (:obj:`bool`, optional): include atoms whose position is :obj:`None`
                                                                  Severity: Minor
                                                                  Found in bpforms/core.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 is_equal has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                  Open

                                                                      def is_equal(self, other):
                                                                          """ Determine if two sequences of monomeric forms are semantically equal
                                                                  
                                                                          Args:
                                                                              other (:obj:`MonomerSequence`): other sequence
                                                                  Severity: Minor
                                                                  Found in bpforms/core.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_hydrogen_atom has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                  Open

                                                                  def get_hydrogen_atom(parent_atom, bonding_hydrogens, i_monomer):
                                                                      """ Get a hydrogen atom attached to a parent atom
                                                                  
                                                                      Args:
                                                                          parent_atom (:obj:`openbabel.OBAtom`): parent atom
                                                                  Severity: Minor
                                                                  Found in bpforms/core.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 __init__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                  Open

                                                                      def __init__(self, seq=None, alphabet=None, backbone=None, bond=None, circular=False,
                                                                                   crosslinks=None, nicks=None):
                                                                          """
                                                                          Args:
                                                                              seq (:obj:`MonomerSequence`, optional): sequence of monomeric forms of the biopolymer
                                                                  Severity: Minor
                                                                  Found in bpforms/core.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