From 3a13fc92f2bc5236dcde66fe5e79e0cea89f1c3d Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Wed, 19 Oct 2022 10:04:35 +0200 Subject: [PATCH] Strict boolean checks MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .../ocpp/1.6/OCPP16IncomingRequestService.ts | 4 ++-- .../ocpp/1.6/OCPP16ResponseService.ts | 14 +++++++------- .../ocpp/1.6/OCPP16ServiceUtils.ts | 4 ++-- src/charging-station/ocpp/OCPPRequestService.ts | 12 +++++++----- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index 1ad01827..aecc08f7 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -281,8 +281,8 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer ): Promise { let response: JsonType; if ( - chargingStation.getOcppStrictCompliance() && - chargingStation.isInPendingState() && + chargingStation.getOcppStrictCompliance() === true && + chargingStation.isInPendingState() === true && (commandName === OCPP16IncomingRequestCommand.REMOTE_START_TRANSACTION || commandName === OCPP16IncomingRequestCommand.REMOTE_STOP_TRANSACTION) ) { diff --git a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts index 4ba89706..b4d8eea2 100644 --- a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts @@ -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 diff --git a/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts b/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts index 741db1d3..25d8dcdf 100644 --- a/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts +++ b/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts @@ -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; diff --git a/src/charging-station/ocpp/OCPPRequestService.ts b/src/charging-station/ocpp/OCPPRequestService.ts index 9fa50b4f..29c740a1 100644 --- a/src/charging-station/ocpp/OCPPRequestService.ts +++ b/src/charging-station/ocpp/OCPPRequestService.ts @@ -159,11 +159,13 @@ export default abstract class OCPPRequestService { } ): Promise { 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; -- 2.34.1