Skip to content

Commit ed6cfcf

Browse files
committed
More strict boolean checks
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
1 parent e6159ce commit ed6cfcf

4 files changed

Lines changed: 20 additions & 13 deletions

File tree

‎src/charging-station/ChargingStation.ts‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,10 @@ export default class ChargingStation {
216216
}
217217

218218
public isRegistered(): boolean {
219-
return !this.isInUnknownState() && (this.isInAcceptedState() || this.isInPendingState());
219+
return (
220+
this.isInUnknownState() === false &&
221+
(this.isInAcceptedState() === true || this.isInPendingState() === true)
222+
);
220223
}
221224

222225
public isChargingStationAvailable(): boolean {
@@ -1326,7 +1329,7 @@ export default class ChargingStation {
13261329
logger.info(
13271330
`${this.logPrefix()} Connection to OCPP server through ${this.wsConnectionUrl.toString()} succeeded`
13281331
);
1329-
if (!this.isRegistered()) {
1332+
if (this.isRegistered() === false) {
13301333
// Send BootNotification
13311334
let registrationRetryCount = 0;
13321335
do {
@@ -1336,7 +1339,7 @@ export default class ChargingStation {
13361339
>(this, RequestCommand.BOOT_NOTIFICATION, this.bootNotificationRequest, {
13371340
skipBufferingOnError: true,
13381341
});
1339-
if (!this.isRegistered()) {
1342+
if (this.isRegistered() === false) {
13401343
this.getRegistrationMaxRetries() !== -1 && registrationRetryCount++;
13411344
await Utils.sleep(
13421345
this.bootNotificationResponse?.interval
@@ -1345,12 +1348,12 @@ export default class ChargingStation {
13451348
);
13461349
}
13471350
} while (
1348-
!this.isRegistered() &&
1351+
this.isRegistered() === false &&
13491352
(registrationRetryCount <= this.getRegistrationMaxRetries() ||
13501353
this.getRegistrationMaxRetries() === -1)
13511354
);
13521355
}
1353-
if (this.isRegistered()) {
1356+
if (this.isRegistered() === true) {
13541357
if (this.isInAcceptedState()) {
13551358
await this.startMessageSequence();
13561359
}

‎src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,12 +298,13 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
298298
);
299299
}
300300
if (
301-
chargingStation.isRegistered() ||
302-
(!chargingStation.getOcppStrictCompliance() && chargingStation.isInUnknownState())
301+
chargingStation.isRegistered() === true ||
302+
(chargingStation.getOcppStrictCompliance() === false &&
303+
chargingStation.isInUnknownState() === true)
303304
) {
304305
if (
305-
this.incomingRequestHandlers.has(commandName) &&
306-
OCPP16ServiceUtils.isIncomingRequestCommandSupported(chargingStation, commandName)
306+
this.incomingRequestHandlers.has(commandName) === true &&
307+
OCPP16ServiceUtils.isIncomingRequestCommandSupported(chargingStation, commandName) === true
307308
) {
308309
try {
309310
this.validatePayload(chargingStation, commandName, commandPayload);

‎src/charging-station/ocpp/1.6/OCPP16RequestService.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export default class OCPP16RequestService extends OCPPRequestService {
149149
commandParams?: JsonType,
150150
params?: RequestParams
151151
): Promise<ResponseType> {
152-
if (OCPP16ServiceUtils.isRequestCommandSupported(chargingStation, commandName)) {
152+
if (OCPP16ServiceUtils.isRequestCommandSupported(chargingStation, commandName) === true) {
153153
const requestPayload = this.buildRequestPayload<RequestType>(
154154
chargingStation,
155155
commandName,

‎src/charging-station/ocpp/1.6/OCPP16ResponseService.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,13 @@ export default class OCPP16ResponseService extends OCPPResponseService {
174174
payload: JsonType,
175175
requestPayload: JsonType
176176
): Promise<void> {
177-
if (chargingStation.isRegistered() || commandName === OCPP16RequestCommand.BOOT_NOTIFICATION) {
177+
if (
178+
chargingStation.isRegistered() === true ||
179+
commandName === OCPP16RequestCommand.BOOT_NOTIFICATION
180+
) {
178181
if (
179-
this.responseHandlers.has(commandName) &&
180-
OCPP16ServiceUtils.isRequestCommandSupported(chargingStation, commandName)
182+
this.responseHandlers.has(commandName) === true &&
183+
OCPP16ServiceUtils.isRequestCommandSupported(chargingStation, commandName) === true
181184
) {
182185
try {
183186
this.validatePayload(chargingStation, commandName, payload);

0 commit comments

Comments
 (0)