build(simulator): silence linter
[e-mobility-charging-stations-simulator.git] / src / charging-station / IdTagsCache.ts
index 0b3ba285dd080777ca60de657fe2060555553536..26ef71318af3bf9cb4834c9b4e07e29faa70e1ba 100644 (file)
@@ -1,7 +1,7 @@
 import { type FSWatcher, readFileSync } from 'node:fs';
 
 import type { ChargingStation } from './ChargingStation';
-import { ChargingStationUtils } from './ChargingStationUtils';
+import { getIdTagsFile } from './ChargingStationUtils';
 import { FileType, IdTagDistribution } from '../types';
 import {
   handleFileException,
@@ -46,10 +46,10 @@ export class IdTagsCache {
   public getIdTag(
     distribution: IdTagDistribution,
     chargingStation: ChargingStation,
-    connectorId: number
+    connectorId: number,
   ): string {
     const hashId = chargingStation.stationInfo.hashId;
-    const idTagsFile = ChargingStationUtils.getIdTagsFile(chargingStation.stationInfo);
+    const idTagsFile = getIdTagsFile(chargingStation.stationInfo);
     switch (distribution) {
       case IdTagDistribution.RANDOM:
         return this.getRandomIdTag(hashId, idTagsFile);
@@ -85,7 +85,7 @@ export class IdTagsCache {
     const addressableKey = this.getIdTagsCacheIndexesAddressableKey(file, hashId);
     this.idTagsCachesAddressableIndexes.set(
       addressableKey,
-      Math.floor(secureRandom() * idTags.length)
+      Math.floor(secureRandom() * idTags.length),
     );
     return idTags[this.idTagsCachesAddressableIndexes.get(addressableKey)];
   }
@@ -97,21 +97,21 @@ export class IdTagsCache {
     const idTag = idTags[idTagIndex];
     this.idTagsCachesAddressableIndexes.set(
       addressableKey,
-      idTagIndex === idTags.length - 1 ? 0 : idTagIndex + 1
+      idTagIndex === idTags.length - 1 ? 0 : idTagIndex + 1,
     );
     return idTag;
   }
 
   private getConnectorAffinityIdTag(chargingStation: ChargingStation, connectorId: number): string {
-    const file = ChargingStationUtils.getIdTagsFile(chargingStation.stationInfo);
+    const file = getIdTagsFile(chargingStation.stationInfo);
     const idTags = this.getIdTags(file);
     const addressableKey = this.getIdTagsCacheIndexesAddressableKey(
       file,
-      chargingStation.stationInfo.hashId
+      chargingStation.stationInfo.hashId,
     );
     this.idTagsCachesAddressableIndexes.set(
       addressableKey,
-      (chargingStation.index - 1 + (connectorId - 1)) % idTags.length
+      (chargingStation.index - 1 + (connectorId - 1)) % idTags.length,
     );
     return idTags[this.idTagsCachesAddressableIndexes.get(addressableKey)];
   }
@@ -132,7 +132,7 @@ export class IdTagsCache {
           if (isNotEmptyString(filename) && event === 'change') {
             try {
               logger.debug(
-                `${this.logPrefix(file)} ${FileType.Authorization} file have changed, reload`
+                `${this.logPrefix(file)} ${FileType.Authorization} file have changed, reload`,
               );
               this.deleteIdTagsCache(file);
               this.deleteIdTagsCacheIndexes(file);
@@ -144,11 +144,11 @@ export class IdTagsCache {
                 this.logPrefix(file),
                 {
                   throwError: false,
-                }
+                },
               );
             }
           }
-        }
+        },
       ),
     });
   }
@@ -185,7 +185,7 @@ export class IdTagsCache {
           file,
           FileType.Authorization,
           error as NodeJS.ErrnoException,
-          this.logPrefix(file)
+          this.logPrefix(file),
         );
       }
     }