oemof/oemof-solph

View on GitHub

Showing 139 of 397 total issues

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

def convert_keys_to_strings(result, keep_none_type=False):
    """
    Convert the dictionary keys to strings.

    All (tuple) keys of the result object e.g. results[(pp1, bus1)] are
Severity: Minor
Found in src/oemof/solph/processing.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 valid_sequence has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

def valid_sequence(sequence, length: int) -> bool:
    """Checks if an object is a numpy array of at least the given length
    or an 'emulated' sequence object of class _FakeSequence.
    If unset, the latter is set to the required lenght.

Severity: Minor
Found in src/oemof/solph/_plumbing.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 _check_and_set_flows has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

def _check_and_set_flows(om, flows, keyword):
    """Checks and sets flows if needed

    Parameters
    ----------
Severity: Minor
Found in src/oemof/solph/constraints/integral_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 12 (exceeds 5 allowed). Consider refactoring.
Open

    def _create(self, group=None):
        """Creates the constraints for
        :class:`oemof.solph.components.experimental._extraction_turbine_chp.ExtractionTurbineCHPBlock`.

        Parameters
Severity: Minor
Found in src/oemof/solph/components/_extraction_turbine_chp.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 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def _create(self, group):
        """Create a storage block for investment modeling"""
        m = self.parent_block()

        # ########################## CHECKS ###################################
Severity: Minor
Found in src/oemof/solph/components/_generic_storage.py - About 1 hr to fix

    Function __init__ has 35 lines of code (exceeds 25 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

      Function main has 34 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(2020, number=len(data))
      Severity: Minor
      Found in examples/generic_invest_limit/example_generic_invest.py - About 1 hr to fix

        Function main has 34 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 main has 33 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 _create has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                def _create(self, group=None):
                    """Creates the balance constraints for the class:`BusBlock` block.
            
                    Parameters
                    ----------
            Severity: Minor
            Found in src/oemof/solph/buses/_bus.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_variables has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                def _create_variables(self, group):
                    r"""Creates all variables for standard flows.
            
                    All *Flow* objects are indexed by a starting and ending node
                    :math:`(i, o)`, which is omitted in the following for the sake of
            Severity: Minor
            Found in src/oemof/solph/flows/_simple_flow_block.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 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def _create(self, group=None):
                    """
                    Create constraints for GenericCHPBlock.
            
                    Parameters
            Severity: Minor
            Found in src/oemof/solph/components/_generic_chp.py - About 1 hr to fix

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

              def main():
                  # *************************************************************************
                  # ********** PART 1 - Define and optimise the energy system ***************
                  # *************************************************************************
              
              
              Severity: Minor
              Found in examples/dual_variable_example/dual_variable_example.py - About 1 hr to fix

                Function _evaluate_remaining_value_difference has 9 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def _evaluate_remaining_value_difference(
                Severity: Major
                Found in src/oemof/solph/flows/_investment_flow_block.py - About 1 hr to fix

                  Function draw_graph has 9 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  def draw_graph(
                  Severity: Major
                  Found in examples/excel_reader/dispatch.py - About 1 hr to fix

                    Function draw_graph has 9 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    def draw_graph(
                    Severity: Major
                    Found in examples/electrical/transshipment.py - About 1 hr to fix

                      Function __init__ has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          def __init__(
                              self,
                              nominal_value=None,
                              variable_costs=0,
                              min=None,
                      Severity: Minor
                      Found in src/oemof/solph/flows/_flow.py - About 1 hr to fix

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

                            def __init__(
                                self,
                                label=None,
                                inputs=None,
                                outputs=None,
                        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

                        Function investment_limit has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def investment_limit(model, limit=None):
                            r"""Set an absolute limit for the total investment costs of an investment
                            optimization problem (over all periods in case of a multi-period model):
                        
                            .. math:: \sum_{investment\_costs} \leq limit
                        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 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def _create(self, group=None):
                                """
                                Create constraints for GenericCHPBlock.
                        
                                Parameters
                        Severity: Minor
                        Found in src/oemof/solph/components/_generic_chp.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