oemof/oemof-solph

View on GitHub

Showing 139 of 397 total issues

File _invest_non_convex_flow_block.py has 262 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-

"""Creating sets, variables, constraints and parts of the objective function
for Flow objects with both Nonconvex and Investment options.

Severity: Minor
Found in src/oemof/solph/flows/_invest_non_convex_flow_block.py - About 2 hrs to fix

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

    def results(model, remove_last_time_point=False):
        """Create a nested result dictionary from the result DataFrame
    
        The already rearranged results from Pyomo from the result DataFrame are
        transferred into a nested dictionary of pandas objects.
    Severity: Minor
    Found in src/oemof/solph/processing.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 _create has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        def _create(self, group=None):
            """Creates the relation for the class:`Link`.
    
            Parameters
            ----------
    Severity: Minor
    Found in src/oemof/solph/components/_link.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 _old_dsm_capacity_rule_end has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

                def _old_dsm_capacity_rule_end(block):
                    """Rule definition for determining old endogenously installed
                    capacity to be decommissioned due to reaching its lifetime.
                    Investment and decommissioning periods are linked within
                    the constraint. The respective decommissioning period is
    Severity: Minor
    Found in src/oemof/solph/components/experimental/_sink_dsm.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

    File _flow.py has 251 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # -*- coding: utf-8 -*-
    
    """
    solph version of oemof.network.Edge
    
    
    Severity: Minor
    Found in src/oemof/solph/flows/_flow.py - About 2 hrs to fix

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

          def __init__(
              self,
              demand,
              capacity_up,
              capacity_down,
      Severity: Minor
      Found in src/oemof/solph/components/experimental/_sink_dsm.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 _create has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def _create(self, group=None):
              """Creates the linear constraint for the class:`ElectricalLine`
              block.
      
              Parameters
      Severity: Minor
      Found in src/oemof/solph/flows/experimental/_electrical_line.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 main has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      def main(dump_and_restore=False):
          # For models that need a long time to optimise, saving and loading the
          # EnergySystem might be advised. By default, we do not do this here. Feel
          # free to experiment with this once you understood the rest of the code.
          dump_results = restore_results = dump_and_restore
      Severity: Minor
      Found in examples/basic_example/basic_example.py - About 1 hr to fix

        Function storage_level_constraint has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

        def storage_level_constraint(
            model,
            name,
            storage_component,
            multiplexer_bus,
        Severity: Minor
        Found in src/oemof/solph/constraints/storage_level.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 main has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        def main():
            data = [0, 15, 30, 35, 20, 25, 27, 10, 5, 2, 15, 40, 20, 0, 0]
        
            # create an energy system
            idx = solph.create_time_index(2017, number=len(data))
        Severity: Minor
        Found in examples/investment_with_minimal_invest/minimal_invest.py - About 1 hr to fix

          Function main has 41 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          def main():
              # Read data file
              filename = os.path.join(os.getcwd(), "tuple_as_label.csv")
              try:
                  data = pd.read_csv(filename)
          Severity: Minor
          Found in examples/tuple_as_labels/tuple_as_label.py - About 1 hr to fix

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

                def __init__(
            Severity: Major
            Found in src/oemof/solph/_options.py - About 1 hr to fix

              Function investment_limit_per_period has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

              def investment_limit_per_period(model, limit=None):
                  r"""Set an absolute limit for the total investment costs of a
                  investment optimization problem for each period
                  of the multi-period problem.
              
              
              Severity: Minor
              Found in src/oemof/solph/constraints/investment_limit.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 _create has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                  def _create(self, group=None):
                      """
                      Create constraints for GenericCAESBlock.
              
                      Parameters
              Severity: Minor
              Found in src/oemof/solph/components/experimental/_generic_caes.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 main has 39 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              def main():
                  # Read data file
                  filename = os.path.join(os.getcwd(), "storage_investment.csv")
                  try:
                      data = pd.read_csv(filename)

                Function storage_level_constraint_example has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                def storage_level_constraint_example():
                    es = EnergySystem(
                        timeindex=pd.date_range("2022-01-01", freq="1H", periods=24),
                        infer_last_interval=True,
                    )
                Severity: Minor
                Found in examples/storage_level_constraint/storage_level_constraint.py - About 1 hr to fix

                  Function main has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  def main():
                      # Read data file
                      filename = os.path.join(os.getcwd(), "variable_chp.csv")
                      try:
                          data = pd.read_csv(filename)
                  Severity: Minor
                  Found in examples/variable_chp/variable_chp.py - About 1 hr to fix

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

                        def __init__(
                    Severity: Major
                    Found in src/oemof/solph/_options.py - About 1 hr to fix

                      Function main has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      def main():
                          # Read data file
                          filename = os.path.join(os.getcwd(), "storage_investment.csv")
                          try:
                              data = pd.read_csv(filename)
                      Severity: Minor
                      Found in examples/storage_investment/v1_invest_optimize_all_technologies.py - About 1 hr to fix

                        Function _objective_expression has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def _objective_expression(self):
                                r"""
                                Objective expression for storages with no investment.
                        
                                Note
                        Severity: Minor
                        Found in src/oemof/solph/components/_generic_storage.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

                        Severity
                        Category
                        Status
                        Source
                        Language