From: Jérôme Benoit Date: Fri, 5 Feb 2021 20:52:56 +0000 (+0100) Subject: Remove uneeded intermediate variable. X-Git-Tag: v1.0.1-0~104^2~17 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=52748e2c6d0b08cecaa3e626f615c92ba6bbf758;p=e-mobility-charging-stations-simulator.git Remove uneeded intermediate variable. Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ocpp/OCPPRequestService.ts b/src/charging-station/ocpp/OCPPRequestService.ts index 6b19d061..6ebb4e38 100644 --- a/src/charging-station/ocpp/OCPPRequestService.ts +++ b/src/charging-station/ocpp/OCPPRequestService.ts @@ -24,7 +24,6 @@ export default abstract class OCPPRequestService { public async sendMessage(messageId: string, commandParams: any, messageType: MessageType = MessageType.CALL_RESULT_MESSAGE, commandName: RequestCommand | IncomingRequestCommand): Promise { // eslint-disable-next-line @typescript-eslint/no-this-alias const self = this; - const chargingStation = this.chargingStation; // Send a message through wsConnection return new Promise((resolve: (value?: any | PromiseLike) => void, reject: (reason?: any) => void) => { let messageToSend: string; @@ -71,8 +70,8 @@ export default abstract class OCPPRequestService { // Function that will receive the request's response async function responseCallback(payload: Record | string, requestPayload: Record): Promise { - if (chargingStation.getEnableStatistics()) { - chargingStation.statistics.addMessage(commandName, messageType); + if (self.chargingStation.getEnableStatistics()) { + self.chargingStation.statistics.addMessage(commandName, messageType); } // Send the response await self.ocppResponseService.handleResponse(commandName as RequestCommand, payload, requestPayload); @@ -81,13 +80,13 @@ export default abstract class OCPPRequestService { // Function that will receive the request's rejection function rejectCallback(error: OCPPError): void { - if (chargingStation.getEnableStatistics()) { - chargingStation.statistics.addMessage(commandName, messageType); + if (self.chargingStation.getEnableStatistics()) { + self.chargingStation.statistics.addMessage(commandName, messageType); } - logger.debug(`${chargingStation.logPrefix()} Error: %j occurred when calling command %s with parameters: %j`, error, commandName, commandParams); + logger.debug(`${self.chargingStation.logPrefix()} Error: %j occurred when calling command %s with parameters: %j`, error, commandName, commandParams); // Build Exception // eslint-disable-next-line no-empty-function - chargingStation.requests[messageId] = [() => { }, () => { }, {}]; // Properly format the request + self.chargingStation.requests[messageId] = [() => { }, () => { }, {}]; // Send error reject(error); }