KarrLab/conv_opt

View on GitHub

Showing 46 of 108 total issues

Function solve has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def solve(self):
        """ Solve the model

        Returns:
            :obj:`Result`: result
Severity: Minor
Found in conv_opt/solver/minos.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

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

    def get_type(self):
        """ Get the type of the model

        Returns:
            :obj:`ModelType`: model type
Severity: Minor
Found in conv_opt/core.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

Function solve has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def solve(self):
        """ Solve the model

        Returns:
            :obj:`Result`: result
Severity: Minor
Found in conv_opt/solver/optlang.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 export has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def export(self, filename, format=None, solver=None):
        """ Export a model to a file in one of these support formats

        * **alp**: model with generic names in lp format, where the variable names are annotated to indicate the type and bounds of each variable
        * **cbf**
Severity: Minor
Found in conv_opt/core.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 convert has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def convert(self, options=None):
        """ Generate a data structure for the model for another package

        Args:
            options (:obj:`SolveOptions`, optional): options
Severity: Minor
Found in conv_opt/core.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

Consider simplifying this complex logical expression.
Open

        if Solver.cbc in preferred_solvers and format in ['lp']:
            from .solver import cbc
            simplex = cbc.CbcModel(self).get_model()
            simplex.writeLp(filename)
        elif Solver.cbc in preferred_solvers and format in ['mps']:
Severity: Critical
Found in conv_opt/core.py - About 1 hr to fix

    Function solve has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def solve(self):
            """ Solve the model
    
            Returns:
                :obj:`Result`: result
    Severity: Minor
    Found in conv_opt/solver/cylp.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 load has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def load(self, conv_opt_model):
            """ Load a model to MINOS' data structure
    
            Args:
                conv_opt_model (:obj:`Model`): model
    Severity: Minor
    Found in conv_opt/solver/minos.py - About 1 hr to fix

      Function solve has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def solve(self):
              """ Solve the model
      
              Returns:
                  :obj:`Result`: result
      Severity: Minor
      Found in conv_opt/solver/minos.py - About 1 hr to fix

        Consider simplifying this complex logical expression.
        Open

                    if constraint.lower_bound is None and constraint.upper_bound is None:
                        raise ConvOptError('Constraints must have at least one bound')
                    elif constraint.lower_bound is None:
                        solver_model.addConstr(lhs, gurobipy.GRB.LESS_EQUAL, constraint.upper_bound, name=constraint.name or '')
                    elif constraint.upper_bound is None:
        Severity: Major
        Found in conv_opt/solver/gurobi.py - About 1 hr to fix

          Function solve has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def solve(self, options=None):
                  """ Solve the model
          
                  Args:
                      options (:obj:`SolveOptions`, optional): options
          Severity: Minor
          Found in conv_opt/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 solve has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def solve(self):
                  """ Solve the model
          
                  Returns:
                      :obj:`Result`: result
          Severity: Minor
          Found in conv_opt/solver/cvxpy.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 __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def __init__(self, solver=Solver.cplex, tune=False, presolve=Presolve.off, precision=64,
          Severity: Major
          Found in conv_opt/core.py - About 50 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if range_constraint:
                                        cobra_model.reactions[i_reaction]._metabolites[met2] += term.coefficient
                                else:
            Severity: Major
            Found in conv_opt/solver/soplex.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if range_constraint:
                                          cobra_model.reactions[i_reaction]._metabolites[met2] = term.coefficient
                              else:
              Severity: Major
              Found in conv_opt/solver/soplex.py - About 45 mins to fix

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

                def makeME_LP(S, b, c, xl, xu, csense):
                Severity: Minor
                Found in conv_opt/solver/minos.py - About 45 mins to fix

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

                      def __init__(self, status_code, status_message, value, primals, reduced_costs, duals):
                  Severity: Minor
                  Found in conv_opt/core.py - About 45 mins to fix

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

                        def __init__(self, name='', variables=None, objective_direction=ObjectiveDirection.minimize, objective_terms=None, constraints=None):
                    Severity: Minor
                    Found in conv_opt/core.py - About 35 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                  return minos.MinosModel(self, options)
                      Severity: Major
                      Found in conv_opt/core.py - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                    return mosek.MosekModel(self, options)
                        Severity: Major
                        Found in conv_opt/core.py - About 30 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language