Showing 5,781 of 10,536 total issues

Avoid deeply nested control flow statements.
Open

                        if current_billing is not None and isinstance(current_billing, Decimal):
                            add_values += " (" + str(microgrid['id']) + ","
                            add_values += "'" + current_datetime_utc.isoformat()[0:19] + "',"
                            add_values += str(current_billing) + "), "
                    print("add_values:" + add_values)
Severity: Major
Found in myems-aggregation/microgrid_billing_discharge.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if cursor:
                                cursor.close()
                            if cnx:
    Severity: Major
    Found in myems-normalization/datarepair.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

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

        Avoid deeply nested control flow statements.
        Open

                            for energy_category_id in energy_category_list:
                                current_factor = factor_dict[energy_category_id]
                                current_energy = energy_dict[current_datetime_utc].get(energy_category_id)
                                if current_factor is not None \
                                        and isinstance(current_factor, Decimal) \
        Severity: Major
        Found in myems-aggregation/tenant_carbon_input_category.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  for energy_category_id in energy_category_list:
                                      current_carbon = carbon_dict[current_datetime_utc].get(energy_category_id)
                                      if current_carbon is not None and isinstance(current_carbon, Decimal):
                                          add_values += " (" + str(tenant['id']) + ","
                                          add_values += " " + str(energy_category_id) + ","
          Severity: Major
          Found in myems-aggregation/tenant_carbon_input_category.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if len(billing_dict[current_datetime_utc]) == 0:
                                    del billing_dict[current_datetime_utc]
            
                        ############################################################################################################
                        # Step 6: save billing data to billing database
            Severity: Major
            Found in myems-aggregation/space_billing_output_category.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      for energy_category_id in energy_category_list:
                                          current_billing = billing_dict[current_datetime_utc].get(energy_category_id)
                                          if current_billing is not None and isinstance(current_billing, Decimal):
                                              add_values += " (" + str(space['id']) + ","
                                              add_values += " " + str(energy_category_id) + ","
              Severity: Major
              Found in myems-aggregation/space_billing_output_category.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if current_datetime_utc not in energy_equipment_hourly[equipment_id]:
                                            energy_equipment_hourly[equipment_id][current_datetime_utc] = dict()
                                        energy_category_id = row_value[1]
                Severity: Major
                Found in myems-aggregation/combined_equipment_energy_output_category.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

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

                    Avoid deeply nested control flow statements.
                    Open

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

                      Avoid deeply nested control flow statements.
                      Open

                                          for energy_category_id in energy_category_list:
                                              current_tariff = tariff_dict[energy_category_id].get(current_datetime_utc)
                                              current_energy = energy_dict[current_datetime_utc].get(energy_category_id)
                                              if current_tariff is not None \
                                                      and isinstance(current_tariff, Decimal) \
                      Severity: Major
                      Found in myems-aggregation/combined_equipment_billing_input_category.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if current_billing is not None and isinstance(current_billing, Decimal):
                                                    add_values += " (" + str(energy_storage_container['id']) + ","
                                                    add_values += "'" + current_datetime_utc.isoformat()[0:19] + "',"
                                                    add_values += str(current_billing) + "), "
                                            print("add_values:" + add_values)
                        Severity: Major
                        Found in myems-aggregation/energy_storage_container_billing_charge.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                              if len(billing_dict[current_datetime_utc]) == 0:
                                                  del billing_dict[current_datetime_utc]
                          
                                      ############################################################################################################
                                      # Step 6: save billing data to billing database
                          Severity: Major
                          Found in myems-aggregation/shopfloor_billing_input_item.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                if current_tariff is not None \
                                                        and isinstance(current_tariff, Decimal) \
                                                        and current_energy is not None \
                                                        and isinstance(current_energy, Decimal):
                                                    billing_dict[current_datetime_utc] = current_energy * current_tariff
                            Severity: Major
                            Found in myems-aggregation/energy_storage_container_billing_charge.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                  if len(carbon_dict[current_datetime_utc]) == 0:
                                                      del carbon_dict[current_datetime_utc]
                              
                                          ############################################################################################################
                                          # Step 6: save carbon dioxide emissions data to database
                              Severity: Major
                              Found in myems-aggregation/combined_equipment_carbon_input_category.py - About 45 mins to fix

                                Function job has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                Open

                                def job(logger):
                                
                                    cnx_historical = None
                                    cursor_historical = None
                                    try:
                                Severity: Minor
                                Found in myems-cleaning/clean_digital_value.py - About 45 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

                                Avoid deeply nested control flow statements.
                                Open

                                                    for energy_category_id in energy_category_list:
                                                        current_factor = factor_dict[energy_category_id]
                                                        current_energy = energy_dict[current_datetime_utc].get(energy_category_id)
                                                        if current_factor is not None \
                                                                and isinstance(current_factor, Decimal) \
                                Severity: Major
                                Found in myems-aggregation/space_carbon_input_category.py - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                      if len(carbon_dict[current_datetime_utc]) == 0:
                                                          del carbon_dict[current_datetime_utc]
                                  
                                              ############################################################################################################
                                              # Step 6: save carbon dioxide emissions data to carbon database
                                  Severity: Major
                                  Found in myems-aggregation/store_carbon_input_category.py - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

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

                                      Avoid deeply nested control flow statements.
                                      Open

                                                              if current_billing is not None and isinstance(current_billing, Decimal):
                                                                  add_values += " (" + str(energy_storage_container['id']) + ","
                                                                  add_values += "'" + current_datetime_utc.isoformat()[0:19] + "',"
                                                                  add_values += str(current_billing) + "), "
                                                          print("add_values:" + add_values)
                                      Severity: Major
                                      Found in myems-aggregation/energy_storage_container_billing_discharge.py - About 45 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language