From bd5d98e0cb5cfb943ad6ac76ba9382cb0bb1f50c Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Thu, 11 May 2023 00:53:46 +0200 Subject: [PATCH] refactor: silence sonar MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts | 4 ++-- src/utils/Utils.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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; } -- 2.34.1