oemof/oemof-solph

View on GitHub
examples/excel_reader/dispatch.py

Summary

Maintainability
F
1 wk
Test Coverage

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

File dispatch.py has 324 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

"""
General description
-------------------
Severity: Minor
Found in examples/excel_reader/dispatch.py - About 3 hrs 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 optimise_scenario has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      def optimise_scenario():
          logger.define_logging()
          datetime_index = pd.date_range(
              "2016-01-01 00:00:00", "2016-01-01 23:00:00", freq="60min"
          )
      Severity: Minor
      Found in examples/excel_reader/dispatch.py - About 1 hr to fix

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

            for i, de in nd["demand"].iterrows():
                if de["active"]:
                    # set static inflow values
                    inflow_args = {"nominal_value": de["nominal value"]}
                    # get time series for node and parameter
        Severity: Major
        Found in examples/excel_reader/dispatch.py and 1 other location - About 1 day to fix
        examples/excel_reader/dispatch.py on lines 178..191

        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 173.

        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

            for i, re in nd["renewables"].iterrows():
                if re["active"]:
                    # set static outflow values
                    outflow_args = {"nominal_value": re["capacity"]}
                    # get time series for node and parameter
        Severity: Major
        Found in examples/excel_reader/dispatch.py and 1 other location - About 1 day to fix
        examples/excel_reader/dispatch.py on lines 196..209

        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 173.

        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

        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

                    if b["excess"]:
                        nodes.append(
                            solph.components.Sink(
                                label=b["label"] + "_excess",
                                inputs={
        Severity: Major
        Found in examples/excel_reader/dispatch.py and 1 other location - About 4 hrs to fix
        examples/excel_reader/dispatch.py on lines 151..157

        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 74.

        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

                    if b["shortage"]:
                        nodes.append(
                            solph.components.Source(
                                label=b["label"] + "_shortage",
                                outputs={
        Severity: Major
        Found in examples/excel_reader/dispatch.py and 1 other location - About 4 hrs to fix
        examples/excel_reader/dispatch.py on lines 140..146

        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 74.

        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

            if edge_labels is True and plt:
                labels = nx.get_edge_attributes(grph, "weight")
                nx.draw_networkx_edge_labels(grph, pos=pos, edge_labels=labels)
        Severity: Major
        Found in examples/excel_reader/dispatch.py and 1 other location - About 1 hr to fix
        examples/electrical/transshipment.py on lines 122..124

        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 43.

        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

                        solph.components.GenericStorage(
                            label=s["label"],
                            inputs={
                                busd[s["bus"]]: solph.Flow(
                                    nominal_value=s["capacity inflow"],
        Severity: Major
        Found in examples/excel_reader/dispatch.py and 1 other location - About 1 hr to fix
        examples/excel_reader/dispatch.py on lines 237..248

        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 42.

        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

            if isinstance(node_color, dict):
                node_color = [node_color.get(g, "#AFAFAF") for g in grph.nodes()]
        Severity: Minor
        Found in examples/excel_reader/dispatch.py and 1 other location - About 35 mins to fix
        examples/electrical/transshipment.py on lines 103..104

        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 33.

        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

        There are no issues that match your filters.

        Category
        Status