From 0638ddd26038a2a45707bc3d43460f09bd95701b Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 11 Sep 2022 17:00:40 +0200 Subject: [PATCH] More strict boolean checks MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- package-lock.json | 150 +++++++++--------- package.json | 2 +- src/charging-station/AuthorizedTagsCache.ts | 4 +- src/charging-station/ChargingStation.ts | 2 +- .../ocpp/OCPPIncomingRequestService.ts | 2 +- .../ocpp/OCPPRequestService.ts | 10 +- .../ocpp/OCPPResponseService.ts | 2 +- 7 files changed, 86 insertions(+), 86 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6e9d182d..8287d747 100644 --- a/package-lock.json +++ b/package-lock.json @@ -56,7 +56,7 @@ "eslint-plugin-jsdoc": "^39.3.6", "eslint-plugin-node": "^11.1.0", "eslint-plugin-prettier": "^4.2.1", - "expect": "^29.0.2", + "expect": "^29.0.3", "husky": "^8.0.1", "lint-staged": "^13.0.3", "mocha": "^10.0.0", @@ -948,9 +948,9 @@ } }, "node_modules/@jest/expect-utils": { - "version": "29.0.2", - "resolved": "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-29.0.2.tgz", - "integrity": "sha512-+wcQF9khXKvAEi8VwROnCWWmHfsJYCZAs5dmuMlJBKk57S6ZN2/FQMIlo01F29fJyT8kV/xblE7g3vkIdTLOjw==", + "version": "29.0.3", + "resolved": "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-29.0.3.tgz", + "integrity": "sha512-i1xUkau7K/63MpdwiRqaxgZOjxYs4f0WMTGJnYwUKubsNRZSeQbLorS7+I4uXVF9KQ5r61BUPAUMZ7Lf66l64Q==", "dev": true, "dependencies": { "jest-get-type": "^29.0.0" @@ -972,9 +972,9 @@ } }, "node_modules/@jest/types": { - "version": "29.0.2", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.0.2.tgz", - "integrity": "sha512-5WNMesBLmlkt1+fVkoCjHa0X3i3q8zc4QLTDkdHgCa2gyPZc7rdlZBWgVLqwS1860ZW5xJuCDwAzqbGaXIr/ew==", + "version": "29.0.3", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.0.3.tgz", + "integrity": "sha512-coBJmOQvurXjN1Hh5PzF7cmsod0zLIOXpP8KD161mqNlroMhLcwpODiEzi7ZsRl5Z/AIuxpeNm8DCl43F4kz8A==", "dev": true, "dependencies": { "@jest/schemas": "^29.0.0", @@ -1661,9 +1661,9 @@ } }, "node_modules/@sinclair/typebox": { - "version": "0.24.34", - "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.24.34.tgz", - "integrity": "sha512-x3ejWKw7rpy30Bvm6U0AQMOHdjqe2E3YJrBHlTxH0KFsp77bBa+MH324nJxtXZFpnTy/JW2h5HPYVm0vG2WPnw==", + "version": "0.24.40", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.24.40.tgz", + "integrity": "sha512-Xint60L8rF0+nRy+6fCjW9jQMmu7fTpbwTBrXZiK6eq/RHDJS7LvWX/0oXC8O7fCePmrY/XdfaTv2HiUDeCq4g==", "dev": true }, "node_modules/@sindresorhus/is": { @@ -6453,16 +6453,16 @@ } }, "node_modules/expect": { - "version": "29.0.2", - "resolved": "https://registry.npmjs.org/expect/-/expect-29.0.2.tgz", - "integrity": "sha512-JeJlAiLKn4aApT4pzUXBVxl3NaZidWIOdg//smaIlP9ZMBDkHZGFd9ubphUZP9pUyDEo7bC6M0IIZR51o75qQw==", + "version": "29.0.3", + "resolved": "https://registry.npmjs.org/expect/-/expect-29.0.3.tgz", + "integrity": "sha512-t8l5DTws3212VbmPL+tBFXhjRHLmctHB0oQbL8eUc6S7NzZtYUhycrFO9mkxA0ZUC6FAWdNi7JchJSkODtcu1Q==", "dev": true, "dependencies": { - "@jest/expect-utils": "^29.0.2", + "@jest/expect-utils": "^29.0.3", "jest-get-type": "^29.0.0", - "jest-matcher-utils": "^29.0.2", - "jest-message-util": "^29.0.2", - "jest-util": "^29.0.2" + "jest-matcher-utils": "^29.0.3", + "jest-message-util": "^29.0.3", + "jest-util": "^29.0.3" }, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" @@ -8943,15 +8943,15 @@ } }, "node_modules/jest-diff": { - "version": "29.0.2", - "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-29.0.2.tgz", - "integrity": "sha512-b9l9970sa1rMXH1owp2Woprmy42qIwwll/htsw4Gf7+WuSp5bZxNhkKHDuCGKL+HoHn1KhcC+tNEeAPYBkD2Jg==", + "version": "29.0.3", + "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-29.0.3.tgz", + "integrity": "sha512-+X/AIF5G/vX9fWK+Db9bi9BQas7M9oBME7egU7psbn4jlszLFCu0dW63UgeE6cs/GANq4fLaT+8sGHQQ0eCUfg==", "dev": true, "dependencies": { "chalk": "^4.0.0", "diff-sequences": "^29.0.0", "jest-get-type": "^29.0.0", - "pretty-format": "^29.0.2" + "pretty-format": "^29.0.3" }, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" @@ -8967,33 +8967,33 @@ } }, "node_modules/jest-matcher-utils": { - "version": "29.0.2", - "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-29.0.2.tgz", - "integrity": "sha512-s62YkHFBfAx0JLA2QX1BlnCRFwHRobwAv2KP1+YhjzF6ZCbCVrf1sG8UJyn62ZUsDaQKpoo86XMTjkUyO5aWmQ==", + "version": "29.0.3", + "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-29.0.3.tgz", + "integrity": "sha512-RsR1+cZ6p1hDV4GSCQTg+9qjeotQCgkaleIKLK7dm+U4V/H2bWedU3RAtLm8+mANzZ7eDV33dMar4pejd7047w==", "dev": true, "dependencies": { "chalk": "^4.0.0", - "jest-diff": "^29.0.2", + "jest-diff": "^29.0.3", "jest-get-type": "^29.0.0", - "pretty-format": "^29.0.2" + "pretty-format": "^29.0.3" }, "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/jest-message-util": { - "version": "29.0.2", - "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-29.0.2.tgz", - "integrity": "sha512-kcJAgms3ckJV0wUoLsAM40xAhY+pb9FVSZwicjFU9PFkaTNmqh9xd99/CzKse48wPM1ANUQKmp03/DpkY+lGrA==", + "version": "29.0.3", + "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-29.0.3.tgz", + "integrity": "sha512-7T8JiUTtDfppojosORAflABfLsLKMLkBHSWkjNQrjIltGoDzNGn7wEPOSfjqYAGTYME65esQzMJxGDjuLBKdOg==", "dev": true, "dependencies": { "@babel/code-frame": "^7.12.13", - "@jest/types": "^29.0.2", + "@jest/types": "^29.0.3", "@types/stack-utils": "^2.0.0", "chalk": "^4.0.0", "graceful-fs": "^4.2.9", "micromatch": "^4.0.4", - "pretty-format": "^29.0.2", + "pretty-format": "^29.0.3", "slash": "^3.0.0", "stack-utils": "^2.0.3" }, @@ -9002,12 +9002,12 @@ } }, "node_modules/jest-util": { - "version": "29.0.2", - "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.0.2.tgz", - "integrity": "sha512-ozk8ruEEEACxqpz0hN9UOgtPZS0aN+NffwQduR5dVlhN+eN47vxurtvgZkYZYMpYrsmlAEx1XabkB3BnN0GfKQ==", + "version": "29.0.3", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.0.3.tgz", + "integrity": "sha512-Q0xaG3YRG8QiTC4R6fHjHQPaPpz9pJBEi0AeOE4mQh/FuWOijFjGXMMOfQEaU9i3z76cNR7FobZZUQnL6IyfdQ==", "dev": true, "dependencies": { - "@jest/types": "^29.0.2", + "@jest/types": "^29.0.3", "@types/node": "*", "chalk": "^4.0.0", "ci-info": "^3.2.0", @@ -12542,9 +12542,9 @@ } }, "node_modules/pretty-format": { - "version": "29.0.2", - "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.0.2.tgz", - "integrity": "sha512-wp3CdtUa3cSJVFn3Miu5a1+pxc1iPIQTenOAn+x5erXeN1+ryTcLesV5pbK/rlW5EKwp27x38MoYfNGaNXDDhg==", + "version": "29.0.3", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.0.3.tgz", + "integrity": "sha512-cHudsvQr1K5vNVLbvYF/nv3Qy/F/BcEKxGuIeMiVMRHxPOO1RxXooP8g/ZrwAp7Dx+KdMZoOc7NxLHhMrP2f9Q==", "dev": true, "dependencies": { "@jest/schemas": "^29.0.0", @@ -18256,9 +18256,9 @@ "dev": true }, "@jest/expect-utils": { - "version": "29.0.2", - "resolved": "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-29.0.2.tgz", - "integrity": "sha512-+wcQF9khXKvAEi8VwROnCWWmHfsJYCZAs5dmuMlJBKk57S6ZN2/FQMIlo01F29fJyT8kV/xblE7g3vkIdTLOjw==", + "version": "29.0.3", + "resolved": "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-29.0.3.tgz", + "integrity": "sha512-i1xUkau7K/63MpdwiRqaxgZOjxYs4f0WMTGJnYwUKubsNRZSeQbLorS7+I4uXVF9KQ5r61BUPAUMZ7Lf66l64Q==", "dev": true, "requires": { "jest-get-type": "^29.0.0" @@ -18274,9 +18274,9 @@ } }, "@jest/types": { - "version": "29.0.2", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.0.2.tgz", - "integrity": "sha512-5WNMesBLmlkt1+fVkoCjHa0X3i3q8zc4QLTDkdHgCa2gyPZc7rdlZBWgVLqwS1860ZW5xJuCDwAzqbGaXIr/ew==", + "version": "29.0.3", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.0.3.tgz", + "integrity": "sha512-coBJmOQvurXjN1Hh5PzF7cmsod0zLIOXpP8KD161mqNlroMhLcwpODiEzi7ZsRl5Z/AIuxpeNm8DCl43F4kz8A==", "dev": true, "requires": { "@jest/schemas": "^29.0.0", @@ -18688,9 +18688,9 @@ } }, "@sinclair/typebox": { - "version": "0.24.34", - "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.24.34.tgz", - "integrity": "sha512-x3ejWKw7rpy30Bvm6U0AQMOHdjqe2E3YJrBHlTxH0KFsp77bBa+MH324nJxtXZFpnTy/JW2h5HPYVm0vG2WPnw==", + "version": "0.24.40", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.24.40.tgz", + "integrity": "sha512-Xint60L8rF0+nRy+6fCjW9jQMmu7fTpbwTBrXZiK6eq/RHDJS7LvWX/0oXC8O7fCePmrY/XdfaTv2HiUDeCq4g==", "dev": true }, "@sindresorhus/is": { @@ -22549,16 +22549,16 @@ } }, "expect": { - "version": "29.0.2", - "resolved": "https://registry.npmjs.org/expect/-/expect-29.0.2.tgz", - "integrity": "sha512-JeJlAiLKn4aApT4pzUXBVxl3NaZidWIOdg//smaIlP9ZMBDkHZGFd9ubphUZP9pUyDEo7bC6M0IIZR51o75qQw==", + "version": "29.0.3", + "resolved": "https://registry.npmjs.org/expect/-/expect-29.0.3.tgz", + "integrity": "sha512-t8l5DTws3212VbmPL+tBFXhjRHLmctHB0oQbL8eUc6S7NzZtYUhycrFO9mkxA0ZUC6FAWdNi7JchJSkODtcu1Q==", "dev": true, "requires": { - "@jest/expect-utils": "^29.0.2", + "@jest/expect-utils": "^29.0.3", "jest-get-type": "^29.0.0", - "jest-matcher-utils": "^29.0.2", - "jest-message-util": "^29.0.2", - "jest-util": "^29.0.2" + "jest-matcher-utils": "^29.0.3", + "jest-message-util": "^29.0.3", + "jest-util": "^29.0.3" } }, "ext": { @@ -24462,15 +24462,15 @@ } }, "jest-diff": { - "version": "29.0.2", - "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-29.0.2.tgz", - "integrity": "sha512-b9l9970sa1rMXH1owp2Woprmy42qIwwll/htsw4Gf7+WuSp5bZxNhkKHDuCGKL+HoHn1KhcC+tNEeAPYBkD2Jg==", + "version": "29.0.3", + "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-29.0.3.tgz", + "integrity": "sha512-+X/AIF5G/vX9fWK+Db9bi9BQas7M9oBME7egU7psbn4jlszLFCu0dW63UgeE6cs/GANq4fLaT+8sGHQQ0eCUfg==", "dev": true, "requires": { "chalk": "^4.0.0", "diff-sequences": "^29.0.0", "jest-get-type": "^29.0.0", - "pretty-format": "^29.0.2" + "pretty-format": "^29.0.3" } }, "jest-get-type": { @@ -24480,41 +24480,41 @@ "dev": true }, "jest-matcher-utils": { - "version": "29.0.2", - "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-29.0.2.tgz", - "integrity": "sha512-s62YkHFBfAx0JLA2QX1BlnCRFwHRobwAv2KP1+YhjzF6ZCbCVrf1sG8UJyn62ZUsDaQKpoo86XMTjkUyO5aWmQ==", + "version": "29.0.3", + "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-29.0.3.tgz", + "integrity": "sha512-RsR1+cZ6p1hDV4GSCQTg+9qjeotQCgkaleIKLK7dm+U4V/H2bWedU3RAtLm8+mANzZ7eDV33dMar4pejd7047w==", "dev": true, "requires": { "chalk": "^4.0.0", - "jest-diff": "^29.0.2", + "jest-diff": "^29.0.3", "jest-get-type": "^29.0.0", - "pretty-format": "^29.0.2" + "pretty-format": "^29.0.3" } }, "jest-message-util": { - "version": "29.0.2", - "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-29.0.2.tgz", - "integrity": "sha512-kcJAgms3ckJV0wUoLsAM40xAhY+pb9FVSZwicjFU9PFkaTNmqh9xd99/CzKse48wPM1ANUQKmp03/DpkY+lGrA==", + "version": "29.0.3", + "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-29.0.3.tgz", + "integrity": "sha512-7T8JiUTtDfppojosORAflABfLsLKMLkBHSWkjNQrjIltGoDzNGn7wEPOSfjqYAGTYME65esQzMJxGDjuLBKdOg==", "dev": true, "requires": { "@babel/code-frame": "^7.12.13", - "@jest/types": "^29.0.2", + "@jest/types": "^29.0.3", "@types/stack-utils": "^2.0.0", "chalk": "^4.0.0", "graceful-fs": "^4.2.9", "micromatch": "^4.0.4", - "pretty-format": "^29.0.2", + "pretty-format": "^29.0.3", "slash": "^3.0.0", "stack-utils": "^2.0.3" } }, "jest-util": { - "version": "29.0.2", - "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.0.2.tgz", - "integrity": "sha512-ozk8ruEEEACxqpz0hN9UOgtPZS0aN+NffwQduR5dVlhN+eN47vxurtvgZkYZYMpYrsmlAEx1XabkB3BnN0GfKQ==", + "version": "29.0.3", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.0.3.tgz", + "integrity": "sha512-Q0xaG3YRG8QiTC4R6fHjHQPaPpz9pJBEi0AeOE4mQh/FuWOijFjGXMMOfQEaU9i3z76cNR7FobZZUQnL6IyfdQ==", "dev": true, "requires": { - "@jest/types": "^29.0.2", + "@jest/types": "^29.0.3", "@types/node": "*", "chalk": "^4.0.0", "ci-info": "^3.2.0", @@ -27252,9 +27252,9 @@ "dev": true }, "pretty-format": { - "version": "29.0.2", - "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.0.2.tgz", - "integrity": "sha512-wp3CdtUa3cSJVFn3Miu5a1+pxc1iPIQTenOAn+x5erXeN1+ryTcLesV5pbK/rlW5EKwp27x38MoYfNGaNXDDhg==", + "version": "29.0.3", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.0.3.tgz", + "integrity": "sha512-cHudsvQr1K5vNVLbvYF/nv3Qy/F/BcEKxGuIeMiVMRHxPOO1RxXooP8g/ZrwAp7Dx+KdMZoOc7NxLHhMrP2f9Q==", "dev": true, "requires": { "@jest/schemas": "^29.0.0", diff --git a/package.json b/package.json index 3c5f1d65..523eb422 100644 --- a/package.json +++ b/package.json @@ -131,7 +131,7 @@ "eslint-plugin-jsdoc": "^39.3.6", "eslint-plugin-node": "^11.1.0", "eslint-plugin-prettier": "^4.2.1", - "expect": "^29.0.2", + "expect": "^29.0.3", "husky": "^8.0.1", "lint-staged": "^13.0.3", "mocha": "^10.0.0", diff --git a/src/charging-station/AuthorizedTagsCache.ts b/src/charging-station/AuthorizedTagsCache.ts index d39fbee6..747b7593 100644 --- a/src/charging-station/AuthorizedTagsCache.ts +++ b/src/charging-station/AuthorizedTagsCache.ts @@ -23,10 +23,10 @@ export default class AuthorizedTagsCache { } public getAuthorizedTags(file: string): string[] { - if (!this.hasTags(file)) { + if (this.hasTags(file) === false) { this.setTags(file, this.getAuthorizedTagsFromFile(file)); // Monitor authorization file - !this.FSWatchers.has(file) && + this.FSWatchers.has(file) === false && this.FSWatchers.set( file, FileUtils.watchJsonFile( diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 32cbc671..1704821c 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -1452,7 +1452,7 @@ export default class ChargingStation { // Incoming Message case MessageType.CALL_MESSAGE: [, , commandName, commandPayload] = request as IncomingRequest; - if (this.getEnableStatistics()) { + if (this.getEnableStatistics() === true) { this.performanceStatistics.addRequestStatistic(commandName, messageType); } logger.debug( diff --git a/src/charging-station/ocpp/OCPPIncomingRequestService.ts b/src/charging-station/ocpp/OCPPIncomingRequestService.ts index 013cb62a..509eebd5 100644 --- a/src/charging-station/ocpp/OCPPIncomingRequestService.ts +++ b/src/charging-station/ocpp/OCPPIncomingRequestService.ts @@ -57,7 +57,7 @@ export default abstract class OCPPIncomingRequestService { schema: JSONSchemaType, payload: T ): boolean { - if (!chargingStation.getPayloadSchemaValidation()) { + if (chargingStation.getPayloadSchemaValidation() === false) { return true; } const validate = this.ajv.compile(schema); diff --git a/src/charging-station/ocpp/OCPPRequestService.ts b/src/charging-station/ocpp/OCPPRequestService.ts index e78ca0c6..7077a28b 100644 --- a/src/charging-station/ocpp/OCPPRequestService.ts +++ b/src/charging-station/ocpp/OCPPRequestService.ts @@ -124,7 +124,7 @@ export default abstract class OCPPRequestService { schema: JSONSchemaType, payload: T ): boolean { - if (!chargingStation.getPayloadSchemaValidation()) { + if (chargingStation.getPayloadSchemaValidation() === false) { return true; } const validate = this.ajv.compile(schema); @@ -175,11 +175,11 @@ export default abstract class OCPPRequestService { responseCallback, errorCallback ); - if (chargingStation.getEnableStatistics()) { + if (chargingStation.getEnableStatistics() === true) { chargingStation.performanceStatistics.addRequestStatistic(commandName, messageType); } // Check if wsConnection opened - if (chargingStation.isWebSocketConnectionOpened()) { + if (chargingStation.isWebSocketConnectionOpened() === true) { // Yes: Send Message const beginId = PerformanceStatistics.beginMeasure(commandName); // FIXME: Handle sending error @@ -190,7 +190,7 @@ export default abstract class OCPPRequestService { messageType )} payload: ${messageToSend}` ); - } else if (!params.skipBufferingOnError) { + } else if (params.skipBufferingOnError === false) { // Buffer it chargingStation.bufferMessage(messageToSend); const ocppError = new OCPPError( @@ -232,7 +232,7 @@ export default abstract class OCPPRequestService { payload: JsonType, requestPayload: JsonType ): Promise { - if (chargingStation.getEnableStatistics()) { + if (chargingStation.getEnableStatistics() === true) { chargingStation.performanceStatistics.addRequestStatistic( commandName, MessageType.CALL_RESULT_MESSAGE diff --git a/src/charging-station/ocpp/OCPPResponseService.ts b/src/charging-station/ocpp/OCPPResponseService.ts index 3faa4351..91b14996 100644 --- a/src/charging-station/ocpp/OCPPResponseService.ts +++ b/src/charging-station/ocpp/OCPPResponseService.ts @@ -35,7 +35,7 @@ export default abstract class OCPPResponseService { schema: JSONSchemaType, payload: T ): boolean { - if (!chargingStation.getPayloadSchemaValidation()) { + if (chargingStation.getPayloadSchemaValidation() === false) { return true; } const validate = this.ajv.compile(schema); -- 2.34.1