From 2035255d4bd926c4acb40acd2b882d2d16174c55 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 5 Sep 2023 18:59:04 +0200 Subject: [PATCH] refactor: cleanup constants namespace MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/charging-station/Bootstrap.ts | 2 +- src/charging-station/ChargingStation.ts | 3 +-- src/charging-station/ocpp/OCPPConstants.ts | 4 ++-- src/charging-station/ocpp/OCPPRequestService.ts | 6 +++--- src/charging-station/ui-server/UIHttpServer.ts | 2 +- src/exception/OCPPError.ts | 2 +- src/utils/Constants.ts | 4 ++-- 7 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/charging-station/Bootstrap.ts b/src/charging-station/Bootstrap.ts index 88c79f4b..00ca6e3c 100644 --- a/src/charging-station/Bootstrap.ts +++ b/src/charging-station/Bootstrap.ts @@ -187,7 +187,7 @@ export class Bootstrap extends EventEmitter { this.uiServer.buildProtocolRequest( generateUUID(), ProcedureName.STOP_CHARGING_STATION, - Constants.EMPTY_FREEZED_OBJECT, + Constants.EMPTY_FROZEN_OBJECT, ), ); await Promise.race([ diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index f8415392..d9f548d7 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -1019,8 +1019,7 @@ export class ChargingStation { } private startReservationExpirationSetInterval(customInterval?: number): void { - const interval = - customInterval ?? Constants.DEFAULT_RESERVATION_EXPIRATION_OBSERVATION_INTERVAL; + const interval = customInterval ?? Constants.DEFAULT_RESERVATION_EXPIRATION_INTERVAL; if (interval > 0) { logger.info( `${this.logPrefix()} Reservation expiration date checks started every ${formatDurationMilliSeconds( diff --git a/src/charging-station/ocpp/OCPPConstants.ts b/src/charging-station/ocpp/OCPPConstants.ts index b9363012..dbe7834b 100644 --- a/src/charging-station/ocpp/OCPPConstants.ts +++ b/src/charging-station/ocpp/OCPPConstants.ts @@ -24,8 +24,8 @@ export class OCPPConstants { MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER, ]); - static readonly OCPP_REQUEST_EMPTY = Constants.EMPTY_FREEZED_OBJECT; - static readonly OCPP_RESPONSE_EMPTY = Constants.EMPTY_FREEZED_OBJECT; + static readonly OCPP_REQUEST_EMPTY = Constants.EMPTY_FROZEN_OBJECT; + static readonly OCPP_RESPONSE_EMPTY = Constants.EMPTY_FROZEN_OBJECT; static readonly OCPP_RESPONSE_ACCEPTED = Object.freeze({ status: GenericStatus.Accepted }); static readonly OCPP_RESPONSE_REJECTED = Object.freeze({ status: GenericStatus.Rejected }); diff --git a/src/charging-station/ocpp/OCPPRequestService.ts b/src/charging-station/ocpp/OCPPRequestService.ts index ccab6468..b489bf08 100644 --- a/src/charging-station/ocpp/OCPPRequestService.ts +++ b/src/charging-station/ocpp/OCPPRequestService.ts @@ -397,7 +397,7 @@ export abstract class OCPPRequestService { ErrorType.GENERIC_ERROR, `WebSocket closed or errored for buffered message id '${messageId}' with content '${messageToSend}'`, commandName, - (messagePayload as JsonObject)?.details ?? Constants.EMPTY_FREEZED_OBJECT, + (messagePayload as JsonObject)?.details ?? Constants.EMPTY_FROZEN_OBJECT, ), ); } else if (wsClosedOrErrored) { @@ -405,7 +405,7 @@ export abstract class OCPPRequestService { ErrorType.GENERIC_ERROR, `WebSocket closed or errored for non buffered message id '${messageId}' with content '${messageToSend}'`, commandName, - (messagePayload as JsonObject)?.details ?? Constants.EMPTY_FREEZED_OBJECT, + (messagePayload as JsonObject)?.details ?? Constants.EMPTY_FROZEN_OBJECT, ); // Reject response if (messageType !== MessageType.CALL_MESSAGE) { @@ -424,7 +424,7 @@ export abstract class OCPPRequestService { ErrorType.GENERIC_ERROR, `Timeout for message id '${messageId}'`, commandName, - (messagePayload as JsonObject)?.details ?? Constants.EMPTY_FREEZED_OBJECT, + (messagePayload as JsonObject)?.details ?? Constants.EMPTY_FROZEN_OBJECT, ), () => { messageType === MessageType.CALL_MESSAGE && chargingStation.requests.delete(messageId); diff --git a/src/charging-station/ui-server/UIHttpServer.ts b/src/charging-station/ui-server/UIHttpServer.ts index e11fd4bd..85dbccdf 100644 --- a/src/charging-station/ui-server/UIHttpServer.ts +++ b/src/charging-station/ui-server/UIHttpServer.ts @@ -133,7 +133,7 @@ export class UIHttpServer extends AbstractUIServer { this.buildProtocolRequest( uuid, procedureName, - body ?? Constants.EMPTY_FREEZED_OBJECT, + body ?? Constants.EMPTY_FROZEN_OBJECT, ), ) .then((protocolResponse?: ProtocolResponse) => { diff --git a/src/exception/OCPPError.ts b/src/exception/OCPPError.ts index 0c69eb23..f624d7e7 100644 --- a/src/exception/OCPPError.ts +++ b/src/exception/OCPPError.ts @@ -24,6 +24,6 @@ export class OCPPError extends BaseError { this.code = code ?? ErrorType.GENERIC_ERROR; this.command = command; - this.details = details ?? Constants.EMPTY_FREEZED_OBJECT; + this.details = details ?? Constants.EMPTY_FROZEN_OBJECT; } } diff --git a/src/utils/Constants.ts b/src/utils/Constants.ts index 60379320..93c5bd9f 100644 --- a/src/utils/Constants.ts +++ b/src/utils/Constants.ts @@ -50,12 +50,12 @@ export class Constants { static readonly STOP_SIMULATOR_TIMEOUT = 120000; // Ms - static readonly EMPTY_FREEZED_OBJECT = Object.freeze({}); + static readonly EMPTY_FROZEN_OBJECT = Object.freeze({}); static readonly EMPTY_FUNCTION = Object.freeze(() => { /* This is intentional */ }); - static readonly DEFAULT_RESERVATION_EXPIRATION_OBSERVATION_INTERVAL = 60000; // Ms + static readonly DEFAULT_RESERVATION_EXPIRATION_INTERVAL = 60000; // Ms private constructor() { // This is intentional -- 2.34.1