KarrLab/wc_lang

View on GitHub
wc_lang/transform/split_reversible_reactions.py

Summary

Maintainability
D
2 days
Test Coverage
A
100%

Function run has a Cognitive Complexity of 96 (exceeds 5 allowed). Consider refactoring.
Open

    def run(self, model):
        """ Split reversible reactions in submodels into separate forward and backward reactions

        Args:
            model (:obj:`Model`): model definition
Severity: Minor
Found in wc_lang/transform/split_reversible_reactions.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

Avoid deeply nested control flow statements.
Open

                        for ot_token in parsed_expr._obj_tables_tokens:
                            if (ot_token.code == ObjTablesTokenCodes.obj_id and
                                issubclass(ot_token.model_type, Reaction) and
                                ot_token.model_id == rxn.id):
                                new_obj_expr_elements.append(f'({rxn_for.id} - {rxn_bck.id})')
Severity: Major
Found in wc_lang/transform/split_reversible_reactions.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if part_back:
                                rxn_bck.participants.append(part_back)
                            else:
                                rxn_bck.participants.create(species=part.species, coefficient=-1 * part.coefficient)
    
    
    Severity: Major
    Found in wc_lang/transform/split_reversible_reactions.py - About 45 mins to fix

      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

        There are no issues that match your filters.

        Category
        Status