oemof/oemof-solph

View on GitHub

Showing 424 of 424 total issues

Function create_nodes has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
Open

def create_nodes(nd=None):
    """Create nodes (oemof objects) from node dict

    Parameters
    ----------
Severity: Minor
Found in examples/excel_reader/dispatch.py - About 7 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_constraints has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
Open

    def _create_constraints(self):
        r"""Creates all constraints for standard flows.

        The following constraints are created, if the appropriate attribute of
        the *Flow* (see :class:`~oemof.solph.flows._flow.Flow`) object is set:
Severity: Minor
Found in src/oemof/solph/flows/_simple_flow_block.py - About 7 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 __init__ has a Cognitive Complexity of 45 (exceeds 5 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 6 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 _simple_flow_block.py has 450 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 neither nonconvex nor investment options.

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

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

        def _objective_expression(self):
            r"""Objective expression for flows with investment attribute of type
            class:`.Investment`. The returned costs are fixed and
            investment costs. Variable costs are added from the standard flow
            objective expression.
    Severity: Minor
    Found in src/oemof/solph/flows/_investment_flow_block.py - About 6 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 offset_diesel_genset_nonconvex_investment.py has 439 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # -*- coding: utf-8 -*-
    
    """
    General description
    -------------------

      File _models.py has 427 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      # -*- coding: utf-8 -*-
      
      """Solph Optimization Models.
      
      SPDX-FileCopyrightText: Uwe Krien <krien@uni-bremen.de>
      Severity: Minor
      Found in src/oemof/solph/_models.py - About 6 hrs to fix

        File _generic_chp.py has 421 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        # -*- coding: utf-8 -
        
        """
        GenericCHP and associated individual constraints (blocks) and groupings.
        
        
        Severity: Minor
        Found in src/oemof/solph/components/_generic_chp.py - About 6 hrs to fix

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              def _max_shutdown_constraint(self):
                  r"""
                  .. math::
                      \sum_{t \in \textrm{TIMESTEPS}} Y_{startup}(t) \leq \
                          N_{shutdown}(i,o)\\
          Severity: Major
          Found in src/oemof/solph/flows/_non_convex_flow_block.py and 1 other location - About 5 hrs to fix
          src/oemof/solph/flows/_non_convex_flow_block.py on lines 611..625

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 97.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              def _max_startup_constraint(self):
                  r"""
                  .. math::
                      \sum_{t \in \textrm{TIMESTEPS}} Y_{startup}(t) \leq \
                          N_{start}(i,o)\\
          Severity: Major
          Found in src/oemof/solph/flows/_non_convex_flow_block.py and 1 other location - About 5 hrs to fix
          src/oemof/solph/flows/_non_convex_flow_block.py on lines 627..641

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 97.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Function _add_parent_block_variables has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
          Open

              def _add_parent_block_variables(self):
                  """Add the parent block variables, which is the `flow` variable,
                  indexed by FLOWS and TIMEINDEX."""
                  self.flow = po.Var(self.FLOWS, self.TIMEINDEX, within=po.Reals)
          
          
          Severity: Minor
          Found in src/oemof/solph/_models.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

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

                                      m.flow[
                                          i,
                                          o,
                                          m.TIMEINDEX[index - 1][0],
                                          m.TIMEINDEX[index - 1][1],
          Severity: Major
          Found in src/oemof/solph/flows/_non_convex_flow_block.py and 1 other location - About 5 hrs to fix
          src/oemof/solph/flows/_non_convex_flow_block.py on lines 743..756

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 92.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              noded["fixed_chp_gas"] = solph.components.Converter(
                  label="fixed_chp_gas",
                  inputs={noded["bgas"]: solph.Flow(nominal_value=0)},
                  outputs={noded["bel"]: solph.Flow(), noded["bth"]: solph.Flow()},
                  conversion_factors={noded["bel"]: 0.3, noded["bth"]: 0.5},
          Severity: Major
          Found in examples/variable_chp/variable_chp.py and 1 other location - About 5 hrs to fix
          examples/variable_chp/variable_chp.py on lines 216..220

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 92.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              noded["fixed_chp_gas_2"] = solph.components.Converter(
                  label="fixed_chp_gas_2",
                  inputs={noded["bgas"]: solph.Flow(nominal_value=10e10)},
                  outputs={noded["bel2"]: solph.Flow(), noded["bth2"]: solph.Flow()},
                  conversion_factors={noded["bel2"]: 0.3, noded["bth2"]: 0.5},
          Severity: Major
          Found in examples/variable_chp/variable_chp.py and 1 other location - About 5 hrs to fix
          examples/variable_chp/variable_chp.py on lines 208..212

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 92.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

                                      m.flow[
                                          i,
                                          o,
                                          m.TIMEINDEX[index][0],
                                          m.TIMEINDEX[index][1],
          Severity: Major
          Found in src/oemof/solph/flows/_non_convex_flow_block.py and 1 other location - About 5 hrs to fix
          src/oemof/solph/flows/_non_convex_flow_block.py on lines 796..802

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 92.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                      nodes.append(
                          solph.components.Converter(
                              label="powerline" + "_" + p["bus_2"] + "_" + p["bus_1"],
                              inputs={bus2: solph.Flow()},
                              outputs={bus1: solph.Flow()},
          Severity: Major
          Found in examples/excel_reader/dispatch.py and 1 other location - About 5 hrs to fix
          examples/excel_reader/dispatch.py on lines 265..270

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 90.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                      nodes.append(
                          solph.components.Converter(
                              label="powerline" + "_" + p["bus_1"] + "_" + p["bus_2"],
                              inputs={bus1: solph.Flow()},
                              outputs={bus2: solph.Flow()},
          Severity: Major
          Found in examples/excel_reader/dispatch.py and 1 other location - About 5 hrs to fix
          examples/excel_reader/dispatch.py on lines 273..278

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 90.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

              def _objective_expression(self):
                  r"""Objective expression for all standard flows with fixed costs
                  and variable costs.
          
                  Depending on the attributes of the `Flow` object the following parts of
          Severity: Minor
          Found in src/oemof/solph/flows/_simple_flow_block.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

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

                              fixed_costs += sum(
                                  m.flows[i, o].nominal_value
                                  * m.flows[i, o].fixed_costs[pp]
                                  * ((1 + m.discount_rate) ** (-pp))
                                  for pp in range(range_limit)
          Severity: Major
          Found in src/oemof/solph/flows/_simple_flow_block.py and 1 other location - About 4 hrs to fix
          src/oemof/solph/flows/_simple_flow_block.py on lines 504..508

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 85.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

                              fixed_costs += sum(
                                  m.flows[i, o].nominal_value
                                  * m.flows[i, o].fixed_costs[pp]
                                  * ((1 + m.discount_rate) ** (-pp))
                                  for pp in range(range_limit)
          Severity: Major
          Found in src/oemof/solph/flows/_simple_flow_block.py and 1 other location - About 4 hrs to fix
          src/oemof/solph/flows/_simple_flow_block.py on lines 517..521

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 85.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Severity
          Category
          Status
          Source
          Language