KarrLab/datanator

View on GitHub
datanator/util/molecule_util.py

Summary

Maintainability
C
1 day
Test Coverage
B
88%

File molecule_util.py has 284 lines of code (exceeds 250 allowed). Consider refactoring.
Open

""" Utilities for dealing with molecules

:Author: Yosef Roth <yosefdroth@gmail.com>
:Author: Jonathan <jonrkarr@gmail.com>
:Date: 2017-04-12
Severity: Minor
Found in datanator/util/molecule_util.py - About 2 hrs to fix

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

        def is_equal(self, other,
                     check_protonation=True, check_double_bonds=True, check_stereochemistry=True,
                     check_isotopes=True, check_fixed_hydrogens=True, check_reconnected_metals=True):
            """ Determine if two molecules are semantically equal (all of their layers are equal).
    
    
    Severity: Minor
    Found in datanator/util/molecule_util.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

    Consider simplifying this complex logical expression.
    Open

            if len(self.structure) >= 7 and self.structure[0:6] == 'InChI=' and \
                    obConversion.SetInFormat('inchi') and \
                    obConversion.ReadString(mol, self.structure):
                return 'inchi'
            elif obConversion.SetInFormat('can') and \
    Severity: Major
    Found in datanator/util/molecule_util.py - About 1 hr to fix

      Function is_equal has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def is_equal(self, other,
      Severity: Major
      Found in datanator/util/molecule_util.py - About 50 mins to fix

        Avoid too many return statements within this function.
        Open

                    return False
        Severity: Major
        Found in datanator/util/molecule_util.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return True
          Severity: Major
          Found in datanator/util/molecule_util.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                        return None
            Severity: Major
            Found in datanator/util/molecule_util.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return False
              Severity: Major
              Found in datanator/util/molecule_util.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                            return False
                Severity: Major
                Found in datanator/util/molecule_util.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                              return False
                  Severity: Major
                  Found in datanator/util/molecule_util.py - About 30 mins to fix

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

                        def __init__(self, structure):
                            """
                            Args:
                                structure (:obj:`str`): InChI-encoded structure of a molecule
                    
                    
                    Severity: Minor
                    Found in datanator/util/molecule_util.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_format has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def get_format(self):
                            """ Get the format of the structure
                    
                            Returns:
                                :obj:`str`: format
                    Severity: Minor
                    Found in datanator/util/molecule_util.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