KarrLab/wc_lang

View on GitHub

Showing 84 of 109 total issues

Function validate_implicit_relationships_are_set has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def validate_implicit_relationships_are_set(self, model, root_model):
        """ Check that there is only one instance of :obj:`root_model` and that each relationship to
        :obj:`root_model` is set. 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 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 import_from_sbml has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def import_from_sbml(self, sbml):
        """ Load from SBML compartment

        Args:
            sbml (:obj:`libsbml.Compartment`): SBML compartment
Severity: Minor
Found in wc_lang/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 create_parameter has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def create_parameter(cls, sbml_model, id, value, units, name=None, constant=True):
Severity: Minor
Found in wc_lang/sbml/util.py - About 45 mins to fix

    Function create_template has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def create_template(path, write_schema=False, write_toc=True,
    Severity: Minor
    Found in wc_lang/io.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if cell.value and isinstance(cell.value, str):
                              cell.value = '!' + cell.value
      
      
      Severity: Major
      Found in migrations/migration_2019_09_20.py - About 45 mins to fix

        Function create_base_unit has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def create_base_unit(cls, unit_def_id, unit_def, kind, exponent=1, scale=0, multiplier=1.0):
        Severity: Minor
        Found in wc_lang/sbml/util.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if cls.call_libsbml(g_child.getName) == 'key':
                                      attr_name = cls.call_libsbml(g_child.toXMLString)[12:-13]
                                  elif cls.call_libsbml(g_child.getName) == 'value':
                                      val = cls.call_libsbml(g_child.toXMLString)[14:-15]
          
          
          Severity: Major
          Found in wc_lang/sbml/util.py - About 45 mins to fix

            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

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

                  def export_relations_to_sbml(self, sbml_model, sbml_rxn):
                      """ Add relationships to/from object to SBML reaction.
              
                      Args:
                          sbml_model (:obj:`libsbml.Model`): SBML model
              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 run has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  def run(self, path, model, models=None, get_related=True, include_all_attributes=False, validate=None,
                          title=None, description=None, keywords=None, version=None, language=None, creator=None,
                          write_schema=False, write_toc=True, extra_entries=0, data_repo_metadata=False, schema_package=None,
                          protected=True):
                      """ Write a list of model classes to an Excel file, with one worksheet for each model, or to
              Severity: Minor
              Found in wc_lang/io.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

                                      for cls_obj in cls_objects:
                                          setattr(cls_obj, attr.name, model)
              
                      # validate
                      config = wc_lang.config.core.get_config()['wc_lang']['io']
              Severity: Major
              Found in wc_lang/io.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

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

                    Function get_children has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

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

                      Avoid deeply nested control flow statements.
                      Open

                                              if species.species_type.structure and species.species_type.structure.has_carbon():
                                                  flux_bounds = carbon_flux_bounds
                                              else:
                                                  flux_bounds = no_carbon_flux_bounds
                      
                      
                      Severity: Major
                      Found in wc_lang/transform/create_implicit_dfba_ex_rxns.py - About 45 mins to fix

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

                            def validate(self):
                                """ Validate that the dFBA objective is valid
                        
                                * Check if the identifier is equal to
                                  `dfba-net-species-{dfba_obj_reaction.id}-{species.id}`
                        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

                        Avoid deeply nested control flow statements.
                        Open

                                                if part.species.has_attr_vals(__type=__type, **kwargs):
                                                    products.append(part.species)
                        
                                # products of dFBA objective reactions
                                for dfba_obj_reaction in self.expression.dfba_obj_reactions:
                        Severity: Major
                        Found in wc_lang/core.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                              if hasattr(wc_lang, table_id):
                                                  table = getattr(wc_lang, table_id)
                                                  table_format = table.Meta.table_format.name
                                              else:
                                                  table_format = 'row'
                          Severity: Major
                          Found in migrations/migration_2020_03_09.py - About 45 mins to fix

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

                                def get_annotations(cls, model_obj, nested_attr_paths, sbml_obj, model_objs=None):
                                    """ Import annotations from a model object to an SBML object
                            
                                    Args:
                                        model_obj (:obj:`obj_tables.Model`): model object
                            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:
                                                        assert rxn.submodel == submodel
                                                        assert rxn.name == name
                                                        assert rxn.participants == participants
                                                        assert rxn.reversible == reversible
                            Severity: Major
                            Found in wc_lang/transform/create_implicit_dfba_ex_rxns.py - About 45 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language