From: Jérôme Benoit Date: Wed, 10 May 2023 22:53:46 +0000 (+0200) Subject: refactor: silence sonar X-Git-Tag: v1.2.14~62 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=bd5d98e0cb5cfb943ad6ac76ba9382cb0bb1f50c;p=e-mobility-charging-stations-simulator.git refactor: silence sonar Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index cfb6efea..b1785a13 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -486,9 +486,9 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { ); if (!keyToChange) { return OCPP16Constants.OCPP_CONFIGURATION_RESPONSE_NOT_SUPPORTED; - } else if (keyToChange && keyToChange.readonly) { + } else if (keyToChange?.readonly === true) { return OCPP16Constants.OCPP_CONFIGURATION_RESPONSE_REJECTED; - } else if (keyToChange && !keyToChange.readonly) { + } else if (keyToChange?.readonly === false) { let valueChanged = false; if (keyToChange.value !== commandPayload.value) { ChargingStationConfigurationUtils.setConfigurationKeyValue( diff --git a/src/utils/Utils.ts b/src/utils/Utils.ts index 37f76911..2724f03f 100644 --- a/src/utils/Utils.ts +++ b/src/utils/Utils.ts @@ -222,11 +222,11 @@ export class Utils { return value == null; } - public static isEmptyArray(object: unknown | unknown[]): boolean { + public static isEmptyArray(object: unknown): boolean { return Array.isArray(object) && object.length === 0; } - public static isNotEmptyArray(object: unknown | unknown[]): boolean { + public static isNotEmptyArray(object: unknown): boolean { return Array.isArray(object) && object.length > 0; }