Showing 5,781 of 10,536 total issues
Avoid deeply nested control flow statements. Open
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) \
Avoid deeply nested control flow statements. Open
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
Avoid deeply nested control flow statements. Open
Open
if current_billing is not None and isinstance(current_billing, Decimal):
add_values += " (" + str(energy_storage_power_station['id']) + ","
add_values += "'" + current_datetime_utc.isoformat()[0:19] + "',"
add_values += str(current_billing) + "), "
print("add_values:" + add_values)
Avoid deeply nested control flow statements. Open
Open
if common_end_datetime_utc > max(energy_hourly.keys()):
common_end_datetime_utc = max(energy_hourly.keys())
Avoid deeply nested control flow statements. Open
Open
if point_value_list[i]['actual_value'] < base_point_value:
# candidate concave value found
concave_point_value_list.append(point_value_list[i]['id'])
else:
# normal value found
Avoid deeply nested control flow statements. Open
Open
for energy_data_item in energy_data_list:
if energy_data_item['point_id'] not in system_point_id_set:
is_valid_file = False
break
# check actual value with point high limit and low limit
Avoid deeply nested control flow statements. Open
Open
if cnx:
cnx.close()
############################################################################################################
# STEP 4: update file status to 'done' or 'error'
Avoid deeply nested control flow statements. Open
Open
if len(file_point_id_set) != 1:
is_valid_file = False
Avoid deeply nested control flow statements. Open
Open
if len(offline_meter_data['data']) > 0:
print("offline_meter_data:" + str(offline_meter_data))
energy_data_list.append(offline_meter_data)
############################################################################################################
Avoid deeply nested control flow statements. Open
Open
if len(carbon_dict[current_datetime_utc]) == 0:
del carbon_dict[current_datetime_utc]
############################################################################################################
# Step 6: save carbon dioxide emissions data to database
Avoid deeply nested control flow statements. Open
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(space['id']) + ","
add_values += " " + str(energy_category_id) + ","
Avoid deeply nested control flow statements. Open
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
Avoid deeply nested control flow statements. Open
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()):
Avoid deeply nested control flow statements. Open
Open
if common_end_datetime_utc > max(energy_hourly.keys()):
common_end_datetime_utc = max(energy_hourly.keys())
Avoid deeply nested control flow statements. Open
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()):
Avoid deeply nested control flow statements. Open
Open
if len(billing_dict[current_datetime_utc]) == 0:
del billing_dict[current_datetime_utc]
############################################################################################################
# Step 6: save billing data to billing database
Avoid deeply nested control flow statements. Open
Open
if aggregated_value['actual_value'] is not None and \
isinstance(aggregated_value['actual_value'], Decimal):
add_values += " (" + str(meter['id']) + ","
add_values += "'" + aggregated_value['start_datetime_utc'].isoformat()[0:19] + "',"
add_values += str(aggregated_value['actual_value']) + "), "
Avoid deeply nested control flow statements. Open
Open
if len(billing_dict[current_datetime_utc]) == 0:
del billing_dict[current_datetime_utc]
############################################################################################################
# Step 6: save billing data to billing database
Avoid deeply nested control flow statements. Open
Open
for energy_item_id in energy_item_list:
current_tariff = tariff_dict[energy_item_id].get(current_datetime_utc)
current_energy = energy_dict[current_datetime_utc].get(energy_item_id)
if current_tariff is not None \
and isinstance(current_tariff, Decimal) \
Function job
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
def job(logger):
cnx_historical = None
cursor_historical = None
try:
- Read upRead up
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"