myems-api/reports/energystoragepowerstationreportingparameters.py

Summary

Maintainability
F
3 days
Test Coverage

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

    def on_get(req, resp):
        if 'API-KEY' not in req.headers or \
                not isinstance(req.headers['API-KEY'], str) or \
                len(str.strip(req.headers['API-KEY'])) == 0:
            access_control(req)
Severity: Minor
Found in myems-api/reports/energystoragepowerstationreportingparameters.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 energystoragepowerstationreportingparameters.py has 380 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import re
from datetime import datetime, timedelta, timezone
from decimal import Decimal
import falcon
import mysql.connector
Severity: Minor
Found in myems-api/reports/energystoragepowerstationreportingparameters.py - About 5 hrs to fix

    Function on_get has 79 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def on_get(req, resp):
            if 'API-KEY' not in req.headers or \
                    not isinstance(req.headers['API-KEY'], str) or \
                    len(str.strip(req.headers['API-KEY'])) == 0:
                access_control(req)
    Severity: Major
    Found in myems-api/reports/energystoragepowerstationreportingparameters.py - About 3 hrs to fix

      Avoid deeply nested control flow statements.
      Open

                              while current_datetime_local < rows[index + 1][0].replace(tzinfo=timezone.utc) + \
                                      timedelta(minutes=timezone_offset):
                                  point_timestamps.append(current_datetime_local.strftime('%m-%d %H:%M'))
                                  point_values.append(rows[index][1])
                                  current_datetime_local += timedelta(minutes=1)
      Severity: Major
      Found in myems-api/reports/energystoragepowerstationreportingparameters.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                while current_datetime_local < rows[index + 1][0].replace(tzinfo=timezone.utc) + \
                                        timedelta(minutes=timezone_offset):
                                    point_timestamps.append(current_datetime_local.strftime('%m-%d %H:%M'))
                                    point_values.append(rows[index][1])
                                    current_datetime_local += timedelta(minutes=1)
        Severity: Major
        Found in myems-api/reports/energystoragepowerstationreportingparameters.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  while current_datetime_local < rows[index + 1][0].replace(tzinfo=timezone.utc) + \
                                          timedelta(minutes=timezone_offset):
                                      point_timestamps.append(current_datetime_local.strftime('%m-%d %H:%M'))
                                      point_values.append(rows[index][1])
                                      current_datetime_local += timedelta(minutes=1)
          Severity: Major
          Found in myems-api/reports/energystoragepowerstationreportingparameters.py - About 45 mins to fix

            There are no issues that match your filters.

            Category
            Status