biosustain/optlang

View on GitHub

Showing 157 of 209 total issues

File versioneer.py has 1650 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Version: 0.29

"""The Versioneer - like a rocketeer, but for versions.

The Versioneer
Severity: Major
Found in versioneer.py - About 4 days to fix

    File interface.py has 1369 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # Copyright 2013 Novo Nordisk Foundation Center for Biosustainability,
    # Technical University of Denmark.
    #
    # Licensed under the Apache License, Version 2.0 (the "License");
    # you may not use this file except in compliance with the License.
    Severity: Major
    Found in src/optlang/interface.py - About 3 days to fix

      File matrix_interface.py has 868 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      # Licensed under the Apache License, Version 2.0 (the "License");
      # you may not use this file except in compliance with the License.
      # You may obtain a copy of the License at
      #
      # http://www.apache.org/licenses/LICENSE-2.0
      Severity: Major
      Found in src/optlang/matrix_interface.py - About 2 days to fix

        File cplex_interface.py has 793 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        # Copyright 2013 Novo Nordisk Foundation Center for Biosustainability,
        # Technical University of Denmark.
        #
        # Licensed under the Apache License, Version 2.0 (the "License");
        # you may not use this file except in compliance with the License.
        Severity: Major
        Found in src/optlang/cplex_interface.py - About 1 day to fix

          File glpk_interface.py has 727 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          # Copyright 2013 Novo Nordisk Foundation Center for Biosustainability,
          # Technical University of Denmark.
          #
          # Licensed under the Apache License, Version 2.0 (the "License");
          # you may not use this file except in compliance with the License.
          Severity: Major
          Found in src/optlang/glpk_interface.py - About 1 day to fix

            Function convert_linear_problem_to_dual has a Cognitive Complexity of 82 (exceeds 5 allowed). Consider refactoring.
            Open

            def convert_linear_problem_to_dual(model, sloppy=False, infinity=None, maintain_standard_form=True, prefix="dual_", dual_model=None):  # NOQA
                """
                A mathematical optimization problem can be viewed as a primal and a dual problem. If the primal problem is
                a minimization problem the dual is a maximization problem, and the optimal value of the dual is a lower bound of
                the optimal value of the primal.
            Severity: Minor
            Found in src/optlang/duality.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

            File gurobi_interface.py has 686 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            # Copyright 2013 Novo Nordisk Foundation Center for Biosustainability,
            # Technical University of Denmark.
            #
            # Licensed under the Apache License, Version 2.0 (the "License");
            # you may not use this file except in compliance with the License.
            Severity: Major
            Found in src/optlang/gurobi_interface.py - About 1 day to fix

              File coinor_cbc_interface.py has 584 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              # Copyright 2013 Novo Nordisk Foundation Center for Biosustainability,
              # Technical University of Denmark.
              #
              # Licensed under the Apache License, Version 2.0 (the "License");
              # you may not use this file except in compliance with the License.
              Severity: Major
              Found in src/optlang/coinor_cbc_interface.py - About 1 day to fix

                File _version.py has 495 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                # This file helps to compute a version number in source trees obtained from
                # git-archive tarball (such as those provided by githubs download-from-tag
                # feature). Distribution tarballs (built by setup.py sdist) and build
                # directories (produced by setup.py build) will contain a much shorter file
                # that just contains the computed version number.
                Severity: Minor
                Found in src/optlang/_version.py - About 7 hrs to fix

                  File scipy_interface.py has 492 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  # Copyright 2015 Novo Nordisk Foundation Center for Biosustainability,
                  # Technical University of Denmark.
                  #
                  # Licensed under the Apache License, Version 2.0 (the "License");
                  # you may not use this file except in compliance with the License.
                  Severity: Minor
                  Found in src/optlang/scipy_interface.py - About 7 hrs to fix

                    Function is_Quadratic has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def is_Quadratic(self):
                            """Returns True if the expression is a polynomial with degree exactly 2 (read-only)."""
                            if self.expression.is_Atom:
                                return False
                            if all((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 5 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

                    Model has 42 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    class Model(object):
                        """
                        The model object represents an optimization problem and contains the variables, constraints an objective that
                        make up the problem. Variables and constraints can be added and removed using the :code:`.add` and :code:`.remove` methods,
                        while the objective can be changed by setting the objective attribute,
                    Severity: Minor
                    Found in src/optlang/interface.py - About 5 hrs to fix

                      Function _initialize_model_from_problem has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def _initialize_model_from_problem(self, problem):
                              if isinstance(problem, cplex.Cplex):
                                  self.problem = problem
                                  zipped_var_args = zip(self.problem.variables.get_names(),
                                                        self.problem.variables.get_lower_bounds(),
                      Severity: Minor
                      Found in src/optlang/cplex_interface.py - About 5 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_cmdclass has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def get_cmdclass(cmdclass: Optional[Dict[str, Any]] = None):
                          """Get the custom setuptools subclasses used by Versioneer.
                      
                          If the package uses a different cmdclass (e.g. one from numpy), it
                          should be provide as an argument.
                      Severity: Minor
                      Found in versioneer.py - About 4 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 git_pieces_from_vcs has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def git_pieces_from_vcs(
                          tag_prefix: str,
                          root: str,
                          verbose: bool,
                          runner: Callable = run_command
                      Severity: Minor
                      Found in versioneer.py - About 3 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 git_pieces_from_vcs has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def git_pieces_from_vcs(
                          tag_prefix: str,
                          root: str,
                          verbose: bool,
                          runner: Callable = run_command
                      Severity: Minor
                      Found in src/optlang/_version.py - About 3 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 _parse_quadratic_expression has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def _parse_quadratic_expression(expression, expanded=False):
                          """
                          Parse a quadratic expression. It is assumed that the expression is known to be quadratic or linear.
                      
                          The 'expanded' parameter tells whether the expression has already been expanded. If it hasn't the parsing
                      Severity: Minor
                      Found in src/optlang/expression_parsing.py - About 3 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

                      Problem has 29 functions (exceeds 20 allowed). Consider refactoring.
                      Open

                      class Problem(object):
                          """
                          Scipy linprog problem. This object implements an object-oriented interface to the linprog solver function.
                          This class is wrapped by the Model object, but can also be used as a stand-alone low-level interface.
                          """
                      Severity: Minor
                      Found in src/optlang/scipy_interface.py - About 3 hrs to fix

                        Configuration has 28 functions (exceeds 20 allowed). Consider refactoring.
                        Open

                        class Configuration(interface.MathematicalProgrammingConfiguration, metaclass=inheritdocstring):
                            def __init__(self, verbosity=0, timeout=None, presolve='auto',
                                         max_nodes=None, max_solutions=None, relax=False,
                                         emphasis=0, cuts=-1, threads=0, *args, **kwargs):
                                super(Configuration, self).__init__(*args, **kwargs)
                        Severity: Minor
                        Found in src/optlang/coinor_cbc_interface.py - About 3 hrs to fix

                          Container has 26 functions (exceeds 20 allowed). Consider refactoring.
                          Open

                          class Container(object):
                              '''
                              A container for objects that have a name attribute.
                              Items in the Container can be accessed by index like a list or by key (the name attribute of the item).
                              For convenience, an item can also be accessed as an attribute with the same name as the name attribute of the item.
                          Severity: Minor
                          Found in src/optlang/container.py - About 3 hrs to fix
                            Severity
                            Category
                            Status
                            Source
                            Language