myems-api/core/utilities.py

Summary

Maintainability
F
1 mo
Test Coverage

Function averaging_hourly_data_by_period has a Cognitive Complexity of 148 (exceeds 5 allowed). Consider refactoring.
Open

def averaging_hourly_data_by_period(rows_hourly, start_datetime_utc, end_datetime_utc, period_type):
    # todo: validate parameters
    if start_datetime_utc is None or \
            end_datetime_utc is None or \
            start_datetime_utc >= end_datetime_utc or \
Severity: Minor
Found in myems-api/core/utilities.py - About 3 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

Function statistics_hourly_data_by_period has a Cognitive Complexity of 118 (exceeds 5 allowed). Consider refactoring.
Open

def statistics_hourly_data_by_period(rows_hourly, start_datetime_utc, end_datetime_utc, period_type):
    # todo: validate parameters
    if start_datetime_utc is None or \
            end_datetime_utc is None or \
            start_datetime_utc >= end_datetime_utc or \
Severity: Minor
Found in myems-api/core/utilities.py - About 2 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 utilities.py has 792 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import collections
import statistics
from datetime import datetime, timedelta
from decimal import Decimal
import mysql.connector
Severity: Major
Found in myems-api/core/utilities.py - About 1 day to fix

    Function aggregate_hourly_data_by_period has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring.
    Open

    def aggregate_hourly_data_by_period(rows_hourly, start_datetime_utc, end_datetime_utc, period_type):
        # todo: validate parameters
        if start_datetime_utc is None or \
                end_datetime_utc is None or \
                start_datetime_utc >= end_datetime_utc or \
    Severity: Minor
    Found in myems-api/core/utilities.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

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

    def get_energy_category_peak_types(cost_center_id, energy_category_id, start_datetime_utc, end_datetime_utc):
        # todo: validate parameters
        if cost_center_id is None:
            return dict()
    
    
    Severity: Minor
    Found in myems-api/core/utilities.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

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

    def get_energy_category_tariffs(cost_center_id, energy_category_id, start_datetime_utc, end_datetime_utc):
        # todo: validate parameters
        if cost_center_id is None:
            return dict()
    
    
    Severity: Minor
    Found in myems-api/core/utilities.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

    Avoid deeply nested control flow statements.
    Open

                        if sub_maximum is None:
                            sub_maximum = row[1]
                        elif sub_maximum < row[1]:
                            sub_maximum = row[1]
                        sub_counter += 1
    Severity: Major
    Found in myems-api/core/utilities.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if sub_maximum is None:
                              sub_maximum = row[1]
                          elif sub_maximum < row[1]:
                              sub_maximum = row[1]
                          sub_counter += 1
      Severity: Major
      Found in myems-api/core/utilities.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if sub_maximum is None:
                                sub_maximum = row[1]
                            elif sub_maximum < row[1]:
                                sub_maximum = row[1]
                            sub_counter += 1
        Severity: Major
        Found in myems-api/core/utilities.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if sub_maximum is None:
                                  sub_maximum = row[1]
                              elif sub_maximum < row[1]:
                                  sub_maximum = row[1]
                              sub_counter += 1
          Severity: Major
          Found in myems-api/core/utilities.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if sub_maximum is None:
                                    sub_maximum = row[1]
                                elif sub_maximum < row[1]:
                                    sub_maximum = row[1]
                                sub_counter += 1
            Severity: Major
            Found in myems-api/core/utilities.py - About 45 mins to fix

              Avoid too many return statements within this function.
              Open

                  return {k: v for k, v in result.items() if start_datetime_utc <= k <= end_datetime_utc}
              Severity: Major
              Found in myems-api/core/utilities.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return list(), None, None, None, None, None, None
                Severity: Major
                Found in myems-api/core/utilities.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                          return list()
                  Severity: Major
                  Found in myems-api/core/utilities.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                        return {k: v for k, v in result.items() if start_datetime_utc <= k <= end_datetime_utc}
                    Severity: Major
                    Found in myems-api/core/utilities.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                              return list(), None, None
                      Severity: Major
                      Found in myems-api/core/utilities.py - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                return result_rows_monthly
                        Severity: Major
                        Found in myems-api/core/utilities.py - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                  return dict()
                          Severity: Major
                          Found in myems-api/core/utilities.py - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                    return result_rows_yearly, average, maximum
                            Severity: Major
                            Found in myems-api/core/utilities.py - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                      return dict()
                              Severity: Major
                              Found in myems-api/core/utilities.py - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                        return result_rows_monthly, average, maximum
                                Severity: Major
                                Found in myems-api/core/utilities.py - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                          return result_rows_monthly, mean, median, minimum, maximum, stdev, variance
                                  Severity: Major
                                  Found in myems-api/core/utilities.py - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                            return result_rows_yearly, mean, median, minimum, maximum, stdev, variance
                                    Severity: Major
                                    Found in myems-api/core/utilities.py - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                              return result_rows_yearly
                                      Severity: Major
                                      Found in myems-api/core/utilities.py - About 30 mins to fix

                                        Function int16_to_hhmm has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                        def int16_to_hhmm(actual_value):
                                            """Convert int16 to time in HH:mm"""
                                            hh = int(actual_value / 256)
                                            if hh < 10:
                                                hh = '0' + str(hh)
                                        Severity: Minor
                                        Found in myems-api/core/utilities.py - About 25 mins 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

                                        def get_energy_category_tariffs(cost_center_id, energy_category_id, start_datetime_utc, end_datetime_utc):
                                            # todo: validate parameters
                                            if cost_center_id is None:
                                                return dict()
                                        
                                        
                                        Severity: Major
                                        Found in myems-api/core/utilities.py and 1 other location - About 1 wk to fix
                                        myems-api/core/utilities.py on lines 253..350

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

                                        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 get_energy_category_peak_types(cost_center_id, energy_category_id, start_datetime_utc, end_datetime_utc):
                                            # todo: validate parameters
                                            if cost_center_id is None:
                                                return dict()
                                        
                                        
                                        Severity: Major
                                        Found in myems-api/core/utilities.py and 1 other location - About 1 wk to fix
                                        myems-api/core/utilities.py on lines 149..246

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

                                        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 current_datetime_utc.month == 1:
                                                        temp_day = 28
                                                        ny = current_datetime_utc.year
                                                        if (ny % 100 != 0 and ny % 4 == 0) or (ny % 100 == 0 and ny % 400 == 0):
                                                            temp_day = 29
                                        Severity: Major
                                        Found in myems-api/core/utilities.py and 1 other location - About 4 days to fix
                                        myems-api/core/utilities.py on lines 504..559

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

                                        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 current_datetime_utc.month == 1:
                                                        temp_day = 28
                                                        ny = current_datetime_utc.year
                                                        if (ny % 100 != 0 and ny % 4 == 0) or (ny % 100 == 0 and ny % 400 == 0):
                                                            temp_day = 29
                                        Severity: Major
                                        Found in myems-api/core/utilities.py and 1 other location - About 4 days to fix
                                        myems-api/core/utilities.py on lines 817..872

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

                                        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

                                                while current_datetime_utc <= end_datetime_utc:
                                                    sub_total = Decimal(0.0)
                                                    sub_maximum = None
                                                    sub_counter = 0
                                                    for row in rows_hourly:
                                        Severity: Major
                                        Found in myems-api/core/utilities.py and 1 other location - About 2 days to fix
                                        myems-api/core/utilities.py on lines 422..445

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

                                        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

                                                while current_datetime_utc <= end_datetime_utc:
                                                    sub_total = Decimal(0.0)
                                                    sub_maximum = None
                                                    sub_counter = 0
                                                    for row in rows_hourly:
                                        Severity: Major
                                        Found in myems-api/core/utilities.py and 1 other location - About 2 days to fix
                                        myems-api/core/utilities.py on lines 462..485

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

                                        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

                                                while current_datetime_utc <= end_datetime_utc:
                                                    sub_total = Decimal(0.0)
                                                    for row in rows_hourly:
                                                        if current_datetime_utc <= row[0] < current_datetime_utc + timedelta(days=1):
                                                            sub_total += row[1]
                                        Severity: Major
                                        Found in myems-api/core/utilities.py and 1 other location - About 1 day to fix
                                        myems-api/core/utilities.py on lines 769..788

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

                                        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

                                                while current_datetime_utc <= end_datetime_utc:
                                                    sub_total = Decimal(0.0)
                                                    for row in rows_hourly:
                                                        if current_datetime_utc <= row[0] < current_datetime_utc + timedelta(days=7):
                                                            sub_total += row[1]
                                        Severity: Major
                                        Found in myems-api/core/utilities.py and 1 other location - About 1 day to fix
                                        myems-api/core/utilities.py on lines 723..742

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

                                        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

                                                    for row in rows_hourly:
                                                        if current_datetime_utc <= row[0] < next_datetime_utc:
                                                            sub_total += row[1]
                                                            if sub_maximum is None:
                                                                sub_maximum = row[1]
                                        Severity: Major
                                        Found in myems-api/core/utilities.py and 1 other location - About 5 hrs to fix
                                        myems-api/core/utilities.py on lines 617..624

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

                                        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

                                                    for row in rows_hourly:
                                                        if current_datetime_utc <= row[0] < next_datetime_utc:
                                                            sub_total += row[1]
                                                            if sub_maximum is None:
                                                                sub_maximum = row[1]
                                        Severity: Major
                                        Found in myems-api/core/utilities.py and 1 other location - About 5 hrs to fix
                                        myems-api/core/utilities.py on lines 567..574

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

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

                                                    next_datetime_utc = datetime(year=current_datetime_utc.year + 2,
                                                                                 month=1,
                                                                                 day=1,
                                                                                 hour=current_datetime_utc.hour,
                                                                                 minute=current_datetime_utc.minute,
                                        Severity: Major
                                        Found in myems-api/core/utilities.py and 2 other locations - About 3 hrs to fix
                                        myems-api/core/utilities.py on lines 126..133
                                        myems-api/core/utilities.py on lines 606..613

                                        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

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

                                                    next_datetime_utc = datetime(year=current_datetime_utc.year + 2,
                                                                                 month=1,
                                                                                 day=1,
                                                                                 hour=current_datetime_utc.hour,
                                                                                 minute=current_datetime_utc.minute,
                                        Severity: Major
                                        Found in myems-api/core/utilities.py and 2 other locations - About 3 hrs to fix
                                        myems-api/core/utilities.py on lines 126..133
                                        myems-api/core/utilities.py on lines 924..931

                                        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

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

                                                    next_datetime_utc = datetime(year=current_datetime_utc.year + 2,
                                                                                 month=1,
                                                                                 day=1,
                                                                                 hour=current_datetime_utc.hour,
                                                                                 minute=current_datetime_utc.minute,
                                        Severity: Major
                                        Found in myems-api/core/utilities.py and 2 other locations - About 3 hrs to fix
                                        myems-api/core/utilities.py on lines 606..613
                                        myems-api/core/utilities.py on lines 924..931

                                        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

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

                                                if len(sample_data) > 1:
                                                    mean = statistics.mean(sample_data)
                                                    median = statistics.median(sample_data)
                                                    stdev = statistics.stdev(sample_data)
                                                    variance = statistics.variance(sample_data)
                                        Severity: Major
                                        Found in myems-api/core/utilities.py and 4 other locations - About 2 hrs to fix
                                        myems-api/core/utilities.py on lines 700..704
                                        myems-api/core/utilities.py on lines 790..794
                                        myems-api/core/utilities.py on lines 897..901
                                        myems-api/core/utilities.py on lines 951..955

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

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

                                                if len(sample_data) > 1:
                                                    mean = statistics.mean(sample_data)
                                                    median = statistics.median(sample_data)
                                                    stdev = statistics.stdev(sample_data)
                                                    variance = statistics.variance(sample_data)
                                        Severity: Major
                                        Found in myems-api/core/utilities.py and 4 other locations - About 2 hrs to fix
                                        myems-api/core/utilities.py on lines 700..704
                                        myems-api/core/utilities.py on lines 744..748
                                        myems-api/core/utilities.py on lines 897..901
                                        myems-api/core/utilities.py on lines 951..955

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

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

                                                if len(sample_data) > 1:
                                                    mean = statistics.mean(sample_data)
                                                    median = statistics.median(sample_data)
                                                    stdev = statistics.stdev(sample_data)
                                                    variance = statistics.variance(sample_data)
                                        Severity: Major
                                        Found in myems-api/core/utilities.py and 4 other locations - About 2 hrs to fix
                                        myems-api/core/utilities.py on lines 744..748
                                        myems-api/core/utilities.py on lines 790..794
                                        myems-api/core/utilities.py on lines 897..901
                                        myems-api/core/utilities.py on lines 951..955

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

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

                                                if len(sample_data) > 1:
                                                    mean = statistics.mean(sample_data)
                                                    median = statistics.median(sample_data)
                                                    stdev = statistics.stdev(sample_data)
                                                    variance = statistics.variance(sample_data)
                                        Severity: Major
                                        Found in myems-api/core/utilities.py and 4 other locations - About 2 hrs to fix
                                        myems-api/core/utilities.py on lines 700..704
                                        myems-api/core/utilities.py on lines 744..748
                                        myems-api/core/utilities.py on lines 790..794
                                        myems-api/core/utilities.py on lines 951..955

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

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

                                                if len(sample_data) > 1:
                                                    mean = statistics.mean(sample_data)
                                                    median = statistics.median(sample_data)
                                                    stdev = statistics.stdev(sample_data)
                                                    variance = statistics.variance(sample_data)
                                        Severity: Major
                                        Found in myems-api/core/utilities.py and 4 other locations - About 2 hrs to fix
                                        myems-api/core/utilities.py on lines 700..704
                                        myems-api/core/utilities.py on lines 744..748
                                        myems-api/core/utilities.py on lines 790..794
                                        myems-api/core/utilities.py on lines 897..901

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

                                        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 row in rows_hourly:
                                                        if current_datetime_utc <= row[0] < current_datetime_utc + \
                                                                timedelta(minutes=config.minutes_to_count):
                                                            subtotal += row[1]
                                        Severity: Major
                                        Found in myems-api/core/utilities.py and 1 other location - About 2 hrs to fix
                                        myems-api/core/utilities.py on lines 679..682

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

                                        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 row in rows_hourly:
                                                        if current_datetime_utc <= row[0] < current_datetime_utc + \
                                                                timedelta(minutes=config.minutes_to_count):
                                                            sub_total += row[1]
                                        Severity: Major
                                        Found in myems-api/core/utilities.py and 1 other location - About 2 hrs to fix
                                        myems-api/core/utilities.py on lines 36..39

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

                                        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 hh < 10:
                                                hh = '0' + str(hh)
                                            elif hh < 24:
                                                hh = str(hh)
                                            else:
                                        Severity: Major
                                        Found in myems-api/core/utilities.py and 1 other location - About 1 hr to fix
                                        myems-api/core/utilities.py on lines 984..989

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

                                        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 mm < 10:
                                                mm = '0' + str(mm)
                                            elif mm < 60:
                                                mm = str(mm)
                                            else:
                                        Severity: Major
                                        Found in myems-api/core/utilities.py and 1 other location - About 1 hr to fix
                                        myems-api/core/utilities.py on lines 977..982

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

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

                                                current_datetime_utc = start_datetime_local.replace(month=1, day=1, hour=0) - timedelta(
                                                    hours=int(config.utc_offset[1:3]))
                                        Severity: Major
                                        Found in myems-api/core/utilities.py and 2 other locations - About 1 hr to fix
                                        myems-api/core/utilities.py on lines 120..121
                                        myems-api/core/utilities.py on lines 600..601

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

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

                                                current_datetime_utc = start_datetime_local.replace(month=1, day=1, hour=0) - timedelta(
                                                    hours=int(config.utc_offset[1:3]))
                                        Severity: Major
                                        Found in myems-api/core/utilities.py and 2 other locations - About 1 hr to fix
                                        myems-api/core/utilities.py on lines 120..121
                                        myems-api/core/utilities.py on lines 918..919

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

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

                                                current_datetime_utc = start_datetime_local.replace(month=1, day=1, hour=0) - timedelta(
                                                    hours=int(config.utc_offset[1:3]))
                                        Severity: Major
                                        Found in myems-api/core/utilities.py and 2 other locations - About 1 hr to fix
                                        myems-api/core/utilities.py on lines 600..601
                                        myems-api/core/utilities.py on lines 918..919

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

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

                                                current_datetime_utc = \
                                                    start_datetime_local.replace(hour=0) - timedelta(days=weekday, hours=int(config.utc_offset[1:3]))
                                        Severity: Major
                                        Found in myems-api/core/utilities.py and 2 other locations - About 1 hr to fix
                                        myems-api/core/utilities.py on lines 69..70
                                        myems-api/core/utilities.py on lines 460..461

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

                                                current_datetime_utc = \
                                                    start_datetime_local.replace(hour=0) - timedelta(days=weekday, hours=int(config.utc_offset[1:3]))
                                        Severity: Major
                                        Found in myems-api/core/utilities.py and 2 other locations - About 1 hr to fix
                                        myems-api/core/utilities.py on lines 460..461
                                        myems-api/core/utilities.py on lines 767..768

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

                                                current_datetime_utc = \
                                                    start_datetime_local.replace(hour=0) - timedelta(days=weekday, hours=int(config.utc_offset[1:3]))
                                        Severity: Major
                                        Found in myems-api/core/utilities.py and 2 other locations - About 1 hr to fix
                                        myems-api/core/utilities.py on lines 69..70
                                        myems-api/core/utilities.py on lines 767..768

                                        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

                                                current_datetime_utc = \
                                                    start_datetime_local.replace(day=1, hour=0) - timedelta(hours=int(config.utc_offset[1:3]))
                                        Severity: Major
                                        Found in myems-api/core/utilities.py and 1 other location - About 1 hr to fix
                                        myems-api/core/utilities.py on lines 812..813

                                        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

                                                current_datetime_utc = \
                                                    start_datetime_local.replace(day=1, hour=0) - timedelta(hours=int(config.utc_offset[1:3]))
                                        Severity: Major
                                        Found in myems-api/core/utilities.py and 1 other location - About 1 hr to fix
                                        myems-api/core/utilities.py on lines 499..500

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

                                                current_datetime_utc = start_datetime_local.replace(hour=0) - timedelta(hours=int(config.utc_offset[1:3]))
                                        Severity: Major
                                        Found in myems-api/core/utilities.py and 4 other locations - About 1 hr to fix
                                        myems-api/core/utilities.py on lines 51..51
                                        myems-api/core/utilities.py on lines 722..722
                                        myems-api/reports/enterproduction.py on lines 177..177
                                        myems-api/reports/offlinemeterdaily.py on lines 148..148

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

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

                                                current_datetime_utc = start_datetime_local.replace(hour=0) - timedelta(hours=int(config.utc_offset[1:3]))
                                        Severity: Major
                                        Found in myems-api/core/utilities.py and 4 other locations - About 1 hr to fix
                                        myems-api/core/utilities.py on lines 421..421
                                        myems-api/core/utilities.py on lines 722..722
                                        myems-api/reports/enterproduction.py on lines 177..177
                                        myems-api/reports/offlinemeterdaily.py on lines 148..148

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

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

                                                current_datetime_utc = start_datetime_local.replace(hour=0) - timedelta(hours=int(config.utc_offset[1:3]))
                                        Severity: Major
                                        Found in myems-api/core/utilities.py and 4 other locations - About 1 hr to fix
                                        myems-api/core/utilities.py on lines 51..51
                                        myems-api/core/utilities.py on lines 421..421
                                        myems-api/reports/enterproduction.py on lines 177..177
                                        myems-api/reports/offlinemeterdaily.py on lines 148..148

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

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

                                            if start_datetime_utc is None or \
                                                    end_datetime_utc is None or \
                                                    start_datetime_utc >= end_datetime_utc or \
                                                    period_type not in ('hourly', 'daily', 'weekly', 'monthly', 'yearly'):
                                        Severity: Major
                                        Found in myems-api/core/utilities.py and 2 other locations - About 1 hr to fix
                                        myems-api/core/utilities.py on lines 364..367
                                        myems-api/core/utilities.py on lines 655..658

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

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

                                            if start_datetime_utc is None or \
                                                    end_datetime_utc is None or \
                                                    start_datetime_utc >= end_datetime_utc or \
                                                    period_type not in ('hourly', 'daily', 'weekly', 'monthly', 'yearly'):
                                        Severity: Major
                                        Found in myems-api/core/utilities.py and 2 other locations - About 1 hr to fix
                                        myems-api/core/utilities.py on lines 20..23
                                        myems-api/core/utilities.py on lines 364..367

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

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

                                            if start_datetime_utc is None or \
                                                    end_datetime_utc is None or \
                                                    start_datetime_utc >= end_datetime_utc or \
                                                    period_type not in ('hourly', 'daily', 'weekly', 'monthly', 'yearly'):
                                        Severity: Major
                                        Found in myems-api/core/utilities.py and 2 other locations - About 1 hr to fix
                                        myems-api/core/utilities.py on lines 20..23
                                        myems-api/core/utilities.py on lines 655..658

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

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

                                                    for row in rows_hourly:
                                                        if current_datetime_utc <= row[0] < next_datetime_utc:
                                                            subtotal += row[1]
                                        Severity: Major
                                        Found in myems-api/core/utilities.py and 4 other locations - About 55 mins to fix
                                        myems-api/core/utilities.py on lines 75..77
                                        myems-api/core/utilities.py on lines 135..137
                                        myems-api/core/utilities.py on lines 878..880
                                        myems-api/core/utilities.py on lines 933..935

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

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

                                                    for row in rows_hourly:
                                                        if current_datetime_utc <= row[0] < next_datetime_utc:
                                                            subtotal += row[1]
                                        Severity: Major
                                        Found in myems-api/core/utilities.py and 4 other locations - About 55 mins to fix
                                        myems-api/core/utilities.py on lines 105..107
                                        myems-api/core/utilities.py on lines 135..137
                                        myems-api/core/utilities.py on lines 878..880
                                        myems-api/core/utilities.py on lines 933..935

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

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

                                                    for row in rows_hourly:
                                                        if current_datetime_utc <= row[0] < next_datetime_utc:
                                                            sub_total += row[1]
                                        Severity: Major
                                        Found in myems-api/core/utilities.py and 4 other locations - About 55 mins to fix
                                        myems-api/core/utilities.py on lines 75..77
                                        myems-api/core/utilities.py on lines 105..107
                                        myems-api/core/utilities.py on lines 135..137
                                        myems-api/core/utilities.py on lines 878..880

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

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

                                                    for row in rows_hourly:
                                                        if current_datetime_utc <= row[0] < next_datetime_utc:
                                                            subtotal += row[1]
                                        Severity: Major
                                        Found in myems-api/core/utilities.py and 4 other locations - About 55 mins to fix
                                        myems-api/core/utilities.py on lines 75..77
                                        myems-api/core/utilities.py on lines 105..107
                                        myems-api/core/utilities.py on lines 878..880
                                        myems-api/core/utilities.py on lines 933..935

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

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

                                                    for row in rows_hourly:
                                                        if current_datetime_utc <= row[0] < next_datetime_utc:
                                                            sub_total += row[1]
                                        Severity: Major
                                        Found in myems-api/core/utilities.py and 4 other locations - About 55 mins to fix
                                        myems-api/core/utilities.py on lines 75..77
                                        myems-api/core/utilities.py on lines 105..107
                                        myems-api/core/utilities.py on lines 135..137
                                        myems-api/core/utilities.py on lines 933..935

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

                                        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