KarrLab/wc_lang

View on GitHub

Showing 84 of 109 total issues

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

                        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

    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

      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

        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

                                  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

            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

              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

                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 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_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 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 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 __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 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 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 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 _default has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def _default(self):
                            args = self.app.pargs
                    
                            if args.compare_files:
                                model1 = read_workbook(args.path_1)
                    Severity: Minor
                    Found in wc_lang/__main__.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 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

                    Severity
                    Category
                    Status
                    Source
                    Language