myems-normalization/virtualmeter.py

Summary

Maintainability
F
2 wks
Test Coverage

Function worker has a Cognitive Complexity of 209 (exceeds 5 allowed). Consider refactoring.
Open

def worker(virtual_meter):
    cnx_energy_db = None
    cursor_energy_db = None

    try:
Severity: Minor
Found in myems-normalization/virtualmeter.py - About 4 days 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 virtualmeter.py has 351 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import random
import time
from datetime import datetime, timedelta
from decimal import Decimal
from multiprocessing import Pool
Severity: Minor
Found in myems-normalization/virtualmeter.py - About 4 hrs to fix

    Function calculate_hourly has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

    def calculate_hourly(logger):
    
        while True:
            # the outermost while loop to reconnect server if there is a connection error
            cnx_system_db = None
    Severity: Minor
    Found in myems-normalization/virtualmeter.py - About 3 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 worker has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def worker(virtual_meter):
        cnx_energy_db = None
        cursor_energy_db = None
    
        try:
    Severity: Minor
    Found in myems-normalization/virtualmeter.py - About 1 hr to fix

      Avoid deeply nested control flow statements.
      Open

                          if common_start_datetime_utc < min(energy_hourly.keys()):
                              common_start_datetime_utc = min(energy_hourly.keys())
                          if common_end_datetime_utc > max(energy_hourly.keys()):
      Severity: Major
      Found in myems-normalization/virtualmeter.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if common_end_datetime_utc > max(energy_hourly.keys()):
                                common_end_datetime_utc = max(energy_hourly.keys())
        
        
        Severity: Major
        Found in myems-normalization/virtualmeter.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if common_start_datetime_utc < min(energy_hourly.keys()):
                                  common_start_datetime_utc = min(energy_hourly.keys())
                              if common_end_datetime_utc > max(energy_hourly.keys()):
          Severity: Major
          Found in myems-normalization/virtualmeter.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if common_end_datetime_utc > max(energy_hourly.keys()):
                                    common_end_datetime_utc = max(energy_hourly.keys())
            
            
            Severity: Major
            Found in myems-normalization/virtualmeter.py - About 45 mins to fix

              Avoid too many return statements within this function.
              Open

                          return "Error in step 3.4 virtual meter worker " + str(e) + " for '" + virtual_meter['name'] + "'"
              Severity: Major
              Found in myems-normalization/virtualmeter.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                            return "Error in step 4.2 virtual meter worker " + str(e) + " for '" + virtual_meter['name'] + "'"
                Severity: Major
                Found in myems-normalization/virtualmeter.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                              return "Error in step 3.3 virtual meter worker " + str(e) + " for '" + virtual_meter['name'] + "'"
                  Severity: Major
                  Found in myems-normalization/virtualmeter.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                return "Error in step 3.2 virtual meter worker " + str(e) + " for '" + virtual_meter['name'] + "'"
                    Severity: Major
                    Found in myems-normalization/virtualmeter.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                              return "Error in step 4.1 virtual meter worker " + str(e) + " for '" + virtual_meter['name'] + "'"
                      Severity: Major
                      Found in myems-normalization/virtualmeter.py - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                return "Error in step 2.1 of virtual meter worker " + str(e) + " for '" + virtual_meter['name'] + "'"
                        Severity: Major
                        Found in myems-normalization/virtualmeter.py - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                              return None
                          Severity: Major
                          Found in myems-normalization/virtualmeter.py - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                    return "Error in step 2.2 of virtual meter worker " + str(e) + " for '" + virtual_meter['name'] + "'"
                            Severity: Major
                            Found in myems-normalization/virtualmeter.py - About 30 mins to fix

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

                                  if offline_meter_list_in_expression is not None and len(offline_meter_list_in_expression) > 0:
                                      try:
                                          for offline_meter_in_expression in offline_meter_list_in_expression:
                                              offline_meter_id = str(offline_meter_in_expression['offline_meter_id'])
                                              query = (" SELECT start_datetime_utc, actual_value "
                              Severity: Major
                              Found in myems-normalization/virtualmeter.py and 2 other locations - About 2 days to fix
                              myems-normalization/virtualmeter.py on lines 259..280
                              myems-normalization/virtualmeter.py on lines 284..306

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

                              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

                                  if meter_list_in_expression is not None and len(meter_list_in_expression) > 0:
                                      try:
                                          for meter_in_expression in meter_list_in_expression:
                                              meter_id = str(meter_in_expression['meter_id'])
                                              query = (" SELECT start_datetime_utc, actual_value "
                              Severity: Major
                              Found in myems-normalization/virtualmeter.py and 2 other locations - About 2 days to fix
                              myems-normalization/virtualmeter.py on lines 284..306
                              myems-normalization/virtualmeter.py on lines 310..332

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

                              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

                                  if virtual_meter_list_in_expression is not None and len(virtual_meter_list_in_expression) > 0:
                                      try:
                                          for virtual_meter_in_expression in virtual_meter_list_in_expression:
                                              virtual_meter_id = str(virtual_meter_in_expression['virtual_meter_id'])
                                              query = (" SELECT start_datetime_utc, actual_value "
                              Severity: Major
                              Found in myems-normalization/virtualmeter.py and 2 other locations - About 2 days to fix
                              myems-normalization/virtualmeter.py on lines 259..280
                              myems-normalization/virtualmeter.py on lines 310..332

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

                              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

                                  try:
                                      cnx_energy_db = mysql.connector.connect(**config.myems_energy_db)
                                      cursor_energy_db = cnx_energy_db.cursor()
                                  except Exception as e:
                                      if cursor_energy_db:
                              Severity: Major
                              Found in myems-normalization/virtualmeter.py and 1 other location - About 5 hrs to fix
                              myems-normalization/virtualpoint.py on lines 105..113

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

                                          if meter_list_in_expression is not None and len(meter_list_in_expression) > 0:
                                              for meter_in_expression in meter_list_in_expression:
                                                  meter_id = str(meter_in_expression['meter_id'])
                                                  actual_value = energy_meter_hourly[meter_id].get(current_datetime_utc, Decimal(0.0))
                                                  subs[meter_in_expression['variable_name']] = actual_value
                              Severity: Major
                              Found in myems-normalization/virtualmeter.py and 2 other locations - About 4 hrs to fix
                              myems-normalization/virtualmeter.py on lines 418..422
                              myems-normalization/virtualmeter.py on lines 424..428

                              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

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

                                          if offline_meter_list_in_expression is not None and len(offline_meter_list_in_expression) > 0:
                                              for offline_meter_in_expression in offline_meter_list_in_expression:
                                                  offline_meter_id = str(offline_meter_in_expression['offline_meter_id'])
                                                  actual_value = energy_offline_meter_hourly[offline_meter_id].get(current_datetime_utc, Decimal(0.0))
                                                  subs[offline_meter_in_expression['variable_name']] = actual_value
                              Severity: Major
                              Found in myems-normalization/virtualmeter.py and 2 other locations - About 4 hrs to fix
                              myems-normalization/virtualmeter.py on lines 412..416
                              myems-normalization/virtualmeter.py on lines 418..422

                              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

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

                                          if virtual_meter_list_in_expression is not None and len(virtual_meter_list_in_expression) > 0:
                                              for virtual_meter_in_expression in virtual_meter_list_in_expression:
                                                  virtual_meter_id = str(virtual_meter_in_expression['virtual_meter_id'])
                                                  actual_value = energy_virtual_meter_hourly[virtual_meter_id].get(current_datetime_utc, Decimal(0.0))
                                                  subs[virtual_meter_in_expression['variable_name']] = actual_value
                              Severity: Major
                              Found in myems-normalization/virtualmeter.py and 2 other locations - About 4 hrs to fix
                              myems-normalization/virtualmeter.py on lines 412..416
                              myems-normalization/virtualmeter.py on lines 424..428

                              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

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

                                      if rows is not None and len(rows) > 0:
                                          for row in rows:
                                              virtual_meter_list_in_expression.append({"virtual_meter_id": row[0],
                                                                                       "variable_name": row[1].lower()})
                              Severity: Major
                              Found in myems-normalization/virtualmeter.py and 2 other locations - About 3 hrs to fix
                              myems-normalization/virtualmeter.py on lines 205..207
                              myems-normalization/virtualmeter.py on lines 236..239

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

                              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

                                      if rows is not None and len(rows) > 0:
                                          for row in rows:
                                              offline_meter_list_in_expression.append({"offline_meter_id": row[0],
                                                                                       "variable_name": row[1].lower()})
                              Severity: Major
                              Found in myems-normalization/virtualmeter.py and 2 other locations - About 3 hrs to fix
                              myems-normalization/virtualmeter.py on lines 205..207
                              myems-normalization/virtualmeter.py on lines 220..223

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

                              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

                                      if rows is not None and len(rows) > 0:
                                          for row in rows:
                                              meter_list_in_expression.append({"meter_id": row[0], "variable_name": row[1].lower()})
                              Severity: Major
                              Found in myems-normalization/virtualmeter.py and 2 other locations - About 3 hrs to fix
                              myems-normalization/virtualmeter.py on lines 220..223
                              myems-normalization/virtualmeter.py on lines 236..239

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

                              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 end_datetime_utc <= start_datetime_utc:
                                      if cursor_energy_db:
                                          cursor_energy_db.close()
                                      if cnx_energy_db:
                                          cnx_energy_db.close()
                              Severity: Major
                              Found in myems-normalization/virtualmeter.py and 1 other location - About 2 hrs to fix
                              myems-normalization/virtualpoint.py on lines 151..156

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

                              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

                                          if rows_virtual_meters is None or len(rows_virtual_meters) == 0:
                                              # sleep several minutes and continue the outer loop to reconnect the database
                                              time.sleep(60)
                                              continue
                              Severity: Major
                              Found in myems-normalization/virtualmeter.py and 2 other locations - About 45 mins to fix
                              myems-normalization/meter.py on lines 49..52
                              myems-normalization/virtualpoint.py on lines 46..49

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

                              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

                                  try:
                                      query = (" SELECT MAX(start_datetime_utc) "
                                               " FROM tbl_virtual_meter_hourly "
                                               " WHERE virtual_meter_id = %s ")
                                      cursor_energy_db.execute(query, (virtual_meter['id'],))
                              Severity: Minor
                              Found in myems-normalization/virtualmeter.py and 1 other location - About 35 mins to fix
                              myems-normalization/meter.py on lines 133..138

                              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