Showing 5,781 of 10,536 total issues

Avoid deeply nested control flow statements.
Open

                        for energy_data_item in energy_data_list:
                            offline_meter_id = energy_data_item['offline_meter_id']
                            print(energy_data_item['data'].items())
                            for start_datetime_utc, daily_value in energy_data_item['data'].items():
                                end_datetime_utc = start_datetime_utc + timedelta(hours=24)
Severity: Major
Found in myems-normalization/offlinemeter.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/combined_equipment_carbon_input_category.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              for row in rows:
                                  point_values_dict[point['point_id']][row[0]] = row[1]
                      elif point_object_type == 'ENERGY_VALUE':
      Severity: Major
      Found in myems-normalization/virtualpoint.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            for cell in row:
                                col_num += 1
                                if not isinstance(cell.value, type(None)):
                                    print(cell.value)
                                if col_num == 1:
        Severity: Major
        Found in myems-normalization/datarepair.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if not isinstance(repair_file_data['point_id'], type(None)):
                                  print("repair_file_data:" + str(repair_file_data))
                                  energy_data_list.append(repair_file_data)
          
                      ############################################################################################################
          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, actual_value in meta_data_dict.items():
                                          aggregated_value['meta_data'][energy_category_id] = \
                                              aggregated_value['meta_data'].get(energy_category_id, Decimal(0.0)) + actual_value
              
              
              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/equipment_energy_input_item.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      for energy_data_item in energy_data_list:
                                          if energy_data_item['offline_meter_id'] not in offline_meter_id_set:
                                              is_valid_file = False
                                              break
                  
                  
                  Severity: Major
                  Found in myems-normalization/offlinemeter.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/offlinemeter.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-aggregation/combined_equipment_energy_output_category.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-aggregation/tenant_energy_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/tenant_energy_input_category.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):
                                                    aggregated_value['actual_value'] = current_energy * current_tariff
                            Severity: Major
                            Found in myems-aggregation/meter_billing.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-aggregation/equipment_energy_input_item.py - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                    for energy_data_item in energy_data_list:
                                                        file_point_id_set.add(energy_data_item['point_id'])
                                
                                                    # limit one point id in one file
                                                    if len(file_point_id_set) != 1:
                                Severity: Major
                                Found in myems-normalization/datarepair.py - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

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

                                    Avoid deeply nested control flow statements.
                                    Open

                                                            if cnx:
                                                                cnx.close()
                                    
                                                ############################################################################################################
                                                # STEP 4: update file status to 'done' or 'error'
                                    Severity: Major
                                    Found in myems-normalization/datarepair.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(store['id']) + ","
                                                                      add_values += " " + str(energy_category_id) + ","
                                      Severity: Major
                                      Found in myems-aggregation/store_carbon_input_category.py - About 45 mins to fix

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

                                        const PaymentsLineChart = () => {
                                          const [paymentStatus, setPaymentStatus] = useState('successful');
                                          const { isDark } = useContext(AppContext);
                                        
                                          const config = {
                                        Severity: Minor
                                        Found in myems-web/src/components/dashboard/PaymentsLineChart.js - 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

                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language