Fix strict boolean checks
authorJérôme Benoit <jerome.benoit@sap.com>
Sat, 24 Sep 2022 22:44:47 +0000 (00:44 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Sat, 24 Sep 2022 22:44:47 +0000 (00:44 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ChargingStation.ts
src/charging-station/ChargingStationUtils.ts
src/charging-station/ChargingStationWorkerBroadcastChannel.ts
src/charging-station/ui-server/ui-services/UIServiceUtils.ts

index 0a3d544a01260c2d051b5f649010aaaa88146c05..90bba2efd58b6a83d64a492d025445221f382f37 100644 (file)
@@ -632,7 +632,7 @@ export default class ChargingStation {
     parentPort.postMessage(MessageChannelUtils.buildUpdatedMessage(this));
   }
 
-  public hasFeatureProfile(featureProfile: SupportedFeatureProfiles) {
+  public hasFeatureProfile(featureProfile: SupportedFeatureProfiles): boolean {
     return ChargingStationConfigurationUtils.getConfigurationKey(
       this,
       StandardParametersKey.SupportedFeatureProfiles
index e6b9c17d53cb9c65bb3d37298983c8484db388d2..370e030ccc5068eb457dc42dfbd3b999c4102864 100644 (file)
@@ -417,7 +417,7 @@ export class ChargingStationUtils {
     phase?: MeterValuePhase
   ): SampledValueTemplate | undefined {
     const onPhaseStr = phase ? `on phase ${phase} ` : '';
-    if (!Constants.SUPPORTED_MEASURANDS.includes(measurand)) {
+    if (Constants.SUPPORTED_MEASURANDS.includes(measurand) === false) {
       logger.warn(
         `${chargingStation.logPrefix()} Trying to get unsupported MeterValues measurand '${measurand}' ${onPhaseStr}in template on connectorId ${connectorId}`
       );
@@ -445,10 +445,10 @@ export class ChargingStationUtils {
       index++
     ) {
       if (
-        !Constants.SUPPORTED_MEASURANDS.includes(
+        Constants.SUPPORTED_MEASURANDS.includes(
           sampledValueTemplates[index]?.measurand ??
             MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER
-        )
+        ) === false
       ) {
         logger.warn(
           `${chargingStation.logPrefix()} Unsupported MeterValues measurand '${measurand}' ${onPhaseStr}in template on connectorId ${connectorId}`
@@ -460,7 +460,7 @@ export class ChargingStationUtils {
         ChargingStationConfigurationUtils.getConfigurationKey(
           chargingStation,
           StandardParametersKey.MeterValuesSampledData
-        )?.value.includes(measurand)
+        )?.value.includes(measurand) === true
       ) {
         return sampledValueTemplates[index];
       } else if (
@@ -470,7 +470,7 @@ export class ChargingStationUtils {
         ChargingStationConfigurationUtils.getConfigurationKey(
           chargingStation,
           StandardParametersKey.MeterValuesSampledData
-        )?.value.includes(measurand)
+        )?.value.includes(measurand) === true
       ) {
         return sampledValueTemplates[index];
       } else if (
@@ -507,9 +507,15 @@ export class ChargingStationUtils {
     chargingStation: ChargingStation
   ): boolean {
     const isRequestCommand = Object.values(RequestCommand).includes(command);
-    if (isRequestCommand && !chargingStation.stationInfo?.commandsSupport?.outgoingCommands) {
+    if (
+      isRequestCommand === true &&
+      !chargingStation.stationInfo?.commandsSupport?.outgoingCommands
+    ) {
       return true;
-    } else if (isRequestCommand && chargingStation.stationInfo?.commandsSupport?.outgoingCommands) {
+    } else if (
+      isRequestCommand === true &&
+      chargingStation.stationInfo?.commandsSupport?.outgoingCommands
+    ) {
       return chargingStation.stationInfo?.commandsSupport?.outgoingCommands[command] ?? false;
     }
     logger.error(`${chargingStation.logPrefix()} Unknown outgoing OCPP command '${command}'`);
@@ -522,12 +528,12 @@ export class ChargingStationUtils {
   ): boolean {
     const isIncomingRequestCommand = Object.values(IncomingRequestCommand).includes(command);
     if (
-      isIncomingRequestCommand &&
+      isIncomingRequestCommand === true &&
       !chargingStation.stationInfo?.commandsSupport?.incomingCommands
     ) {
       return true;
     } else if (
-      isIncomingRequestCommand &&
+      isIncomingRequestCommand === true &&
       chargingStation.stationInfo?.commandsSupport?.incomingCommands
     ) {
       return chargingStation.stationInfo?.commandsSupport?.incomingCommands[command] ?? false;
index 00780f2f6ed0000c352b0d417ea567ddc2ea1382..274267ca446ade938bfd2e519fdf692a5b2f29d7 100644 (file)
@@ -268,7 +268,7 @@ export default class ChargingStationWorkerBroadcastChannel extends WorkerBroadca
     [
       BroadcastChannelProcedureName.START_AUTOMATIC_TRANSACTION_GENERATOR,
       BroadcastChannelProcedureName.STOP_AUTOMATIC_TRANSACTION_GENERATOR,
-    ].includes(command) === false && delete requestPayload.connectorIds;
+    ].includes(command) === true && delete requestPayload.connectorIds;
   }
 
   private commandResponseToResponsePayload(
index c019982854c22d73bcc446ca3a2ecc56caa1aca1..a3cb11b14ac9b177a0ca19ff0565ad3b9be5fa5c 100644 (file)
@@ -36,7 +36,8 @@ export class UIServiceUtils {
     protocol: Protocol,
     version: ProtocolVersion
   ): boolean =>
-    Object.values(Protocol).includes(protocol) && Object.values(ProtocolVersion).includes(version);
+    Object.values(Protocol).includes(protocol) === true &&
+    Object.values(ProtocolVersion).includes(version) === true;
 
   public static getProtocolAndVersion = (protocolStr: string): [Protocol, ProtocolVersion] => {
     const protocolIndex = protocolStr.indexOf(Protocol.UI);