biosustain/optlang

View on GitHub

Showing 157 of 209 total issues

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

    def __init__(self, lp_method='primal', presolve="auto", verbosity=0, timeout=None,
Severity: Major
Found in src/optlang/cplex_interface.py - About 1 hr to fix

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

    def render_pep440_pre(pieces: Dict[str, Any]) -> str:
        """TAG[.postN.devDISTANCE] -- No -dirty.
    
        Exceptions:
        1: no tags. 0.post0.devDISTANCE
    Severity: Minor
    Found in src/optlang/_version.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 solution_target has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def solution_target(self, value):
            if self.problem is not None:
                params = self.problem.problem.parameters
                try:
                    solution_target = params.optimalitytarget
    Severity: Minor
    Found in src/optlang/cplex_interface.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 _add_variables has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def _add_variables(self, variables):
            super(Model, self)._add_variables(variables)
            lb, ub, vtype, names, coeff = list(), list(), list(), list(), list()
            for variable in variables:
                if variable.lb is None:
    Severity: Minor
    Found in src/optlang/cplex_interface.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 is_Linear has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def is_Linear(self):
            """Returns True if expression is linear (a polynomial with degree 1 or 0) (read-only)."""
            coeff_dict = self.expression.as_coefficients_dict()
            for key in coeff_dict.keys():
                if len(key.free_symbols) < 2 and (key.is_Add or key.is_Mul or key.is_Atom):
    Severity: Minor
    Found in src/optlang/interface.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 _get_expression has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def _get_expression(self):
            if self.problem is not None and self._expression_expired:
                variables = self.problem._variables
    
                def term_generator():
    Severity: Minor
    Found in src/optlang/glpk_interface.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 render_pep440_pre has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def render_pep440_pre(pieces: Dict[str, Any]) -> str:
        """TAG[.postN.devDISTANCE] -- No -dirty.
    
        Exceptions:
        1: no tags. 0.post0.devDISTANCE
    Severity: Minor
    Found in versioneer.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 __setstate__ has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def __setstate__(self, state):
            for key, val in state.items():
                if key != 'tolerances':
                    setattr(self, key, val)
            # TODO: remove if check before final merge. Only here for backwards
    Severity: Minor
    Found in src/optlang/coinor_cbc_interface.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 parse_optimization_expression has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def parse_optimization_expression(obj, linear=True, quadratic=False, expression=None, **kwargs):
        """
        Function for parsing the expression of a Constraint or Objective object.
    
        Parameters
    Severity: Minor
    Found in src/optlang/expression_parsing.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 render_pep440_old has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def render_pep440_old(pieces: Dict[str, Any]) -> str:
        """TAG[.postDISTANCE[.dev0]] .
    
        The ".dev0" means dirty.
    
    
    Severity: Minor
    Found in src/optlang/_version.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 render_pep440_old has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def render_pep440_old(pieces: Dict[str, Any]) -> str:
        """TAG[.postDISTANCE[.dev0]] .
    
        The ".dev0" means dirty.
    
    
    Severity: Minor
    Found in versioneer.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, lp_method='primal', qp_method='primal', presolve=False,
    Severity: Major
    Found in src/optlang/gurobi_interface.py - About 50 mins to fix

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

          def __init__(self, name, lb=None, ub=None, type="continuous", problem=None, *args, **kwargs):
      Severity: Major
      Found in src/optlang/interface.py - About 50 mins to fix

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

            def __init__(self, name=None, objective=None, variables=None, constraints=None, problem=None, *args, **kwargs):
        Severity: Major
        Found in src/optlang/interface.py - About 50 mins to fix

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

              def __init__(self, expression, lb=None, ub=None, indicator_variable=None, active_when=1, *args, **kwargs):
          Severity: Major
          Found in src/optlang/interface.py - About 50 mins to fix

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

                def type(self, value):
                    if self.problem is not None:
                        try:
                            cplex_kind = _VTYPE_TO_CPLEX_VTYPE[value]
                        except KeyError:
            Severity: Minor
            Found in src/optlang/cplex_interface.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_command has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def run_command(
            Severity: Minor
            Found in src/optlang/_version.py - About 45 mins to fix

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

                  def __init__(self, expression, name=None, problem=None, sloppy=False, *args, **kwargs):
              Severity: Minor
              Found in src/optlang/interface.py - About 45 mins to fix

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

                    def __init__(
                Severity: Minor
                Found in src/optlang/matrix_interface.py - About 45 mins to fix

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

                      def _canonicalize(self, expression):
                          expression = super(Constraint, self)._canonicalize(expression)
                          if expression.is_Atom or expression.is_Mul:
                              return expression
                          lonely_coeffs = [arg for arg in expression.args if arg.is_Number]
                  Severity: Minor
                  Found in src/optlang/interface.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

                  Severity
                  Category
                  Status
                  Source
                  Language