oemof/oemof-solph

View on GitHub

Showing 424 of 424 total issues

File _sink_dsm.py has 4619 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

"""
Implementation of demand-side management (demand response) which allows for

Severity: Major
Found in src/oemof/solph/components/experimental/_sink_dsm.py - About 1 wk to fix

    File _generic_storage.py has 1618 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # -*- coding: utf-8 -
    
    """
    GenericStorage and associated individual constraints (blocks) and groupings.
    
    
    Severity: Major
    Found in src/oemof/solph/components/_generic_storage.py - About 4 days to fix

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

          def _shutdown_costs(self):
              r"""
              .. math::
                  \sum_{SHUTDOWNFLOWS} \sum_t Y_{shutdown}(t) \
                  \cdot c_{shutdown}
      Severity: Major
      Found in src/oemof/solph/flows/_non_convex_flow_block.py and 2 other locations - About 3 days to fix
      src/oemof/solph/flows/_non_convex_flow_block.py on lines 317..349
      src/oemof/solph/flows/_non_convex_flow_block.py on lines 385..417

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

      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 3 locations. Consider refactoring.
      Open

          def _activity_costs(self):
              r"""
              .. math::
                  \sum_{ACTIVITYCOSTFLOWS} \sum_t Y_{status}(t) \
                  \cdot c_{activity}
      Severity: Major
      Found in src/oemof/solph/flows/_non_convex_flow_block.py and 2 other locations - About 3 days to fix
      src/oemof/solph/flows/_non_convex_flow_block.py on lines 317..349
      src/oemof/solph/flows/_non_convex_flow_block.py on lines 351..383

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

      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 3 locations. Consider refactoring.
      Open

          def _startup_costs(self):
              r"""
              .. math::
                  \sum_{i, o \in STARTUPFLOWS} \sum_t  Y_{startup}(t) \
                  \cdot c_{startup}
      Severity: Major
      Found in src/oemof/solph/flows/_non_convex_flow_block.py and 2 other locations - About 3 days to fix
      src/oemof/solph/flows/_non_convex_flow_block.py on lines 351..383
      src/oemof/solph/flows/_non_convex_flow_block.py on lines 385..417

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

      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

      File _investment_flow_block.py has 957 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 investment but without nonconvex option.
      
      
      Severity: Major
      Found in src/oemof/solph/flows/_investment_flow_block.py - About 2 days to fix

        File _non_convex_flow_block.py has 730 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 nonconvex but without investment options.
        
        
        Severity: Major
        Found in src/oemof/solph/flows/_non_convex_flow_block.py - About 1 day to fix

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

              def _create(self, group=None):
                  """Create a storage block for investment modeling"""
                  m = self.parent_block()
                  if group is None:
                      return None
          Severity: Minor
          Found in src/oemof/solph/components/_generic_storage.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

          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

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

              if plt is not None:
                  # plot heat bus
                  data = solph.views.node(results, "b_heat")["sequences"]
                  exclude = ["excess_heat", "status"]
                  columns = [
          examples/invest_nonconvex_flow_examples/house_with_nonconvex_investment.py on lines 142..155

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

          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 plt is not None:
                  # plot heat bus
                  data = solph.views.node(results, "b_heat")["sequences"]
                  exclude = ["excess_heat", "status"]
                  columns = [
          examples/invest_nonconvex_flow_examples/house_without_nonconvex_investment.py on lines 157..170

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

          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 _create_constraints has a Cognitive Complexity of 65 (exceeds 5 allowed). Consider refactoring.
          Open

              def _create_constraints(self):
                  r"""Creates all constraints for standard flows.
          
                  Depending on the attributes of the *InvestmentFlowBlock*
                  and *SimpleFlowBlock*, different constraints are created.
          Severity: Minor
          Found in src/oemof/solph/flows/_investment_flow_block.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 _generic_caes.py has 574 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          # -*- coding: utf-8 -*-
          
          """
          In-development generic compressed air energy storage.
          
          
          Severity: Major
          Found in src/oemof/solph/components/experimental/_generic_caes.py - About 1 day to fix

            File processing.py has 526 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            # -*- coding: utf-8 -*-
            
            """Modules for providing a convenient data structure for solph results.
            
            Information about the possible usage is provided within the examples.
            Severity: Major
            Found in src/oemof/solph/processing.py - About 1 day to fix

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

              def node_output_by_type(results, node_type, droplevel=None):
                  """Gets all outputs for all nodes of the type `node_type` and returns
                  a dataframe.
              
                  Parameters
              Severity: Major
              Found in src/oemof/solph/views.py and 1 other location - About 1 day to fix
              src/oemof/solph/views.py on lines 268..309

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

              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 node_input_by_type(results, node_type, droplevel=None):
                  """Gets all inputs for all nodes of the type `node_type` and returns
                  a dataframe.
              
                  Parameters
              Severity: Major
              Found in src/oemof/solph/views.py and 1 other location - About 1 day to fix
              src/oemof/solph/views.py on lines 312..352

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

              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

              Severity: Major
              Found in src/oemof/solph/components/_source.py and 1 other location - About 1 day to fix
              src/oemof/solph/components/_sink.py on lines 0..72

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

              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

              Severity: Major
              Found in src/oemof/solph/components/_sink.py and 1 other location - About 1 day to fix
              src/oemof/solph/components/_source.py on lines 0..82

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

              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 __separate_attrs has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
              Open

              def __separate_attrs(
                  system, exclude_attrs, get_flows=False, exclude_none=True
              ):
                  """
                  Create a dictionary with flow scalars and series.
              Severity: Minor
              Found in src/oemof/solph/processing.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

              Severity
              Category
              Status
              Source
              Language