Strict boolean checks
authorJérôme Benoit <jerome.benoit@sap.com>
Wed, 19 Oct 2022 08:04:35 +0000 (10:04 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Wed, 19 Oct 2022 08:04:35 +0000 (10:04 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts
src/charging-station/ocpp/1.6/OCPP16ResponseService.ts
src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts
src/charging-station/ocpp/OCPPRequestService.ts

index 1ad01827f1519aef033590f68254323484dc1fab..aecc08f786ccfe0d119260cfd2bb498688008230 100644 (file)
@@ -281,8 +281,8 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
   ): Promise<void> {
     let response: JsonType;
     if (
-      chargingStation.getOcppStrictCompliance() &&
-      chargingStation.isInPendingState() &&
+      chargingStation.getOcppStrictCompliance() === true &&
+      chargingStation.isInPendingState() === true &&
       (commandName === OCPP16IncomingRequestCommand.REMOTE_START_TRANSACTION ||
         commandName === OCPP16IncomingRequestCommand.REMOTE_STOP_TRANSACTION)
     ) {
index 4ba89706feb8a4a38a52edcad386f880122090e9..b4d8eea2a3b79c615f048aee2938aa55bc419f13 100644 (file)
@@ -338,8 +338,8 @@ export default class OCPP16ResponseService extends OCPPResponseService {
     }
     if (
       chargingStation.getConnectorStatus(connectorId).transactionRemoteStarted === true &&
-      chargingStation.getAuthorizeRemoteTxRequests() &&
-      chargingStation.getLocalAuthListEnabled() &&
+      chargingStation.getAuthorizeRemoteTxRequests() === true &&
+      chargingStation.getLocalAuthListEnabled() === true &&
       chargingStation.hasAuthorizedTags() &&
       chargingStation.getConnectorStatus(connectorId).idTagLocalAuthorized === false
     ) {
@@ -355,8 +355,8 @@ export default class OCPP16ResponseService extends OCPPResponseService {
     }
     if (
       chargingStation.getConnectorStatus(connectorId).transactionRemoteStarted === true &&
-      chargingStation.getAuthorizeRemoteTxRequests() &&
-      chargingStation.getMustAuthorizeAtRemoteStart() &&
+      chargingStation.getAuthorizeRemoteTxRequests() === true &&
+      chargingStation.getMustAuthorizeAtRemoteStart() === true &&
       chargingStation.getConnectorStatus(connectorId).idTagLocalAuthorized === false &&
       chargingStation.getConnectorStatus(connectorId).idTagAuthorized === false
     ) {
@@ -542,9 +542,9 @@ export default class OCPP16ResponseService extends OCPPResponseService {
       return;
     }
     if (payload.idTagInfo?.status === OCPP16AuthorizationStatus.ACCEPTED) {
-      chargingStation.getBeginEndMeterValues() &&
-        !chargingStation.getOcppStrictCompliance() &&
-        chargingStation.getOutOfOrderEndMeterValues() &&
+      chargingStation.getBeginEndMeterValues() === true &&
+        chargingStation.getOcppStrictCompliance() === false &&
+        chargingStation.getOutOfOrderEndMeterValues() === true &&
         (await chargingStation.ocppRequestService.requestHandler<
           OCPP16MeterValuesRequest,
           OCPP16MeterValuesResponse
index 741db1d32a948a910ae5a968dc24a7316014dd97..25d8dcdf4a8fb33f9e2a5e43ec486f757d534878 100644 (file)
@@ -641,9 +641,9 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils {
       // Persist previous value on connector
       if (
         connector &&
-        !Utils.isNullOrUndefined(connector.energyActiveImportRegisterValue) &&
+        Utils.isNullOrUndefined(connector.energyActiveImportRegisterValue) === false &&
         connector.energyActiveImportRegisterValue >= 0 &&
-        !Utils.isNullOrUndefined(connector.transactionEnergyActiveImportRegisterValue) &&
+        Utils.isNullOrUndefined(connector.transactionEnergyActiveImportRegisterValue) === false &&
         connector.transactionEnergyActiveImportRegisterValue >= 0
       ) {
         connector.energyActiveImportRegisterValue += energyValueRounded;
index 9fa50b4f2f53a7dc7f2b6f982208f4441451d87f..29c740a187310d11fe5a0dedf4ea3e05de8d016c 100644 (file)
@@ -159,11 +159,13 @@ export default abstract class OCPPRequestService {
     }
   ): Promise<ResponseType> {
     if (
-      (chargingStation.isInUnknownState() && commandName === RequestCommand.BOOT_NOTIFICATION) ||
-      (!chargingStation.getOcppStrictCompliance() && chargingStation.isInUnknownState()) ||
-      chargingStation.isInAcceptedState() ||
-      (chargingStation.isInPendingState() &&
-        (params.triggerMessage || messageType === MessageType.CALL_RESULT_MESSAGE))
+      (chargingStation.isInUnknownState() === true &&
+        commandName === RequestCommand.BOOT_NOTIFICATION) ||
+      (chargingStation.getOcppStrictCompliance() === false &&
+        chargingStation.isInUnknownState() === true) ||
+      chargingStation.isInAcceptedState() === true ||
+      (chargingStation.isInPendingState() === true &&
+        (params.triggerMessage === true || messageType === MessageType.CALL_RESULT_MESSAGE))
     ) {
       // eslint-disable-next-line @typescript-eslint/no-this-alias
       const self = this;