KarrLab/wc_lang

View on GitHub

Showing 84 of 109 total issues

Avoid deeply nested control flow statements.
Open

                        for i_author in range(cls.call_libsbml(sbml_authors.getNumChildren, returns_int=True)):
                            sbml_au = cls.call_libsbml(sbml_authors.getChild, i_author)
                            au = model.authors.create()
                            for i_prop in range(cls.call_libsbml(sbml_au.getNumChildren, returns_int=True)):
                                sbml_prop = cls.call_libsbml(sbml_au.getChild, i_prop)
Severity: Major
Found in wc_lang/sbml/util.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if submodel.dfba_obj.expression.expression:
                                merged_dfba_expression.append(submodel.dfba_obj.expression.expression)
                            for rxn in list(submodel.dfba_obj.expression.reactions):
    Severity: Major
    Found in wc_lang/transform/merge_submodels.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              for rxn in list(submodel.dfba_obj.expression.reactions):
                                  submodel.dfba_obj.expression.reactions.remove(rxn)
                                  objs_for_merged_dfba_expression[Reaction][rxn.id] = rxn
                              for dfba_obj_rxn in list(submodel.dfba_obj.expression.dfba_obj_reactions):
      Severity: Major
      Found in wc_lang/transform/merge_submodels.py - About 45 mins to fix

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

            def remove_metadata(model):
                """ Remove metadata from model
        
                Args:
                    model (:obj:`wc_utils.workbook.Workbook`): model
        Severity: Minor
        Found in wc_lang/__main__.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

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

            def get_errors_warnings(cls, sbml_doc):
                """ Get libSBML errors and warnings
        
                Args:
                    sbml_doc (:obj:`libsbml.SBMLDocument`): SBML document
        Severity: Minor
        Found in wc_lang/sbml/util.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 rxn.flux_bounds:
                                    if not math.isnan(rxn.flux_bounds.min) and not math.isnan(rxn.flux_bounds.max):
                                        # assume flux_bounds.min <= flux_bounds.max
                                        assert rxn.flux_bounds.min <= rxn.flux_bounds.max, \
                                            f"min flux bound greater than max in {rxn.id}"
        Severity: Major
        Found in wc_lang/transform/split_reversible_reactions.py - About 45 mins to fix

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

              def validate(self):
                  """ Determine if the model is valid
          
                  * Network of compartments is rooted and acyclic
                  * Networks of observables and functions are acyclic
          Severity: Minor
          Found in wc_lang/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

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

          def transform(filename):
              # read
              wb = openpyxl.load_workbook(filename=filename)
          
              for ws in wb:
          Severity: Minor
          Found in migrations/migration_2020_04_27.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 cell.value and isinstance(cell.value, str):
                                  cell.value = '!' + cell.value
                  else:
          Severity: Major
          Found in migrations/migration_2019_09_20.py - About 45 mins to fix

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

                def get_immediate_children(self, kind=None, __type=None, __include_stop_conditions=True,
            Severity: Minor
            Found in wc_lang/core.py - About 35 mins to fix

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

                  def parse_units(cls, sbml_model):
                      """ Parse SBML units to Python
              
                      Args:
                          sbml_model (:obj:`libsbml.Model`): SBML model
              Severity: Minor
              Found in wc_lang/sbml/util.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 run has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def run(cls, model):
                      """ Encode a `wc_lang` model with at most 1 submodel into SBML
              
                      * Validate model
                      * Create SBML document
              Severity: Minor
              Found in wc_lang/sbml/io.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 validate_implicit_relationships has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def validate_implicit_relationships(cls, root_model):
                      """ Check that relationships to :obj:`root_model` do not need to be explicitly exported because
                          they can be inferred by :obj:`Reader.run`. This is necessary to enable the relationships
                          to :obj:`root_model` to not be exported in workbooks, and instead added by :obj:`Reader.run`.
              
              
              Severity: Minor
              Found in wc_lang/io.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 import_relations_from_sbml has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def import_relations_from_sbml(self, sbml, objs):
                      """ Load relationships from SBML compartment
              
                      Args:
                          sbml (:obj:`libsbml.Compartment`): SBML compartment
              Severity: Minor
              Found in wc_lang/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

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

                  def __getitem__(cls, name):
                      """ Get value by name
              
                      Args:
                          name (:obj:`str`): attribute name
              Severity: Minor
              Found in wc_lang/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

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

                  def get_species(self, __type=None, **kwargs):
                      """ Get species
              
                      Args:
                          __type (:obj:`types.TypeType` or :obj:`tuple` of :obj:`types.TypeType`): subclass(es) of :obj:`Model`
              Severity: Minor
              Found in wc_lang/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

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

                  def validate(self):
                      """ Check that the compartment is valid
              
                      * Check that the units of density are `g l^-1`
              
              
              Severity: Minor
              Found in wc_lang/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

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

                      def gbl_part(self, *args):
                          coeff = 1.
                          for arg in args:
                              if arg.type == 'SPECIES_COEFFICIENT__SPECIES__SPECIES_TYPE__ID':
                                  if arg.value not in self.objects.get(SpeciesType, {}):
              Severity: Minor
              Found in wc_lang/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

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

                  def validate(self):
                      """ Determine if the submodel is valid
              
                      * dFBA submodel has an objective
              
              
              Severity: Minor
              Found in wc_lang/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 _serialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def _serialize(species, coefficient, show_compartment=True, show_coefficient_sign=True):
                      """ Serialize values
              
                      Args:
                          species (:obj:`Species`): species
              Severity: Minor
              Found in wc_lang/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

              Severity
              Category
              Status
              Source
              Language