More strict boolean checks
authorJérôme Benoit <jerome.benoit@sap.com>
Sun, 11 Sep 2022 15:00:40 +0000 (17:00 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Sun, 11 Sep 2022 15:00:40 +0000 (17:00 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
package-lock.json
package.json
src/charging-station/AuthorizedTagsCache.ts
src/charging-station/ChargingStation.ts
src/charging-station/ocpp/OCPPIncomingRequestService.ts
src/charging-station/ocpp/OCPPRequestService.ts
src/charging-station/ocpp/OCPPResponseService.ts

index 6e9d182d5904f604078616f3c0e60a65443dac34..8287d74731f39ee6a98b17f11795eb823ee18cd3 100644 (file)
@@ -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",
       }
     },
     "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"
       }
     },
     "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",
       }
     },
     "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": {
       }
     },
     "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"
       }
     },
     "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"
       }
     },
     "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"
       },
       }
     },
     "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",
       }
     },
     "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",
       "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"
       }
     },
     "@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",
       }
     },
     "@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": {
       }
     },
     "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": {
       }
     },
     "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": {
       "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",
       "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",
index 3c5f1d65e7523af5dd5addfd60015c0d04db1ba3..523eb422f00ec834c8389013fc0ed8214a58c073 100644 (file)
     "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",
index d39fbee61e6fa6e27a13fbddbab25dbdffee2d06..747b7593e422d5ef123444170a6cbc470a8333b0 100644 (file)
@@ -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(
index 32cbc671ab2e7d35b49bd75efc00a6ab5802f27d..1704821c053dca9e843c100c7d703bff082b61bd 100644 (file)
@@ -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(
index 013cb62ad8235c002cf3e4d97fd65d3af5643412..509eebd57b16bd8beacb924aafba3b5e2c5e8423 100644 (file)
@@ -57,7 +57,7 @@ export default abstract class OCPPIncomingRequestService {
     schema: JSONSchemaType<T>,
     payload: T
   ): boolean {
-    if (!chargingStation.getPayloadSchemaValidation()) {
+    if (chargingStation.getPayloadSchemaValidation() === false) {
       return true;
     }
     const validate = this.ajv.compile(schema);
index e78ca0c6dfa4d8fcec3049d05b67a11d62df82de..7077a28bb88c839590516e3af49a2b82964e8c5b 100644 (file)
@@ -124,7 +124,7 @@ export default abstract class OCPPRequestService {
     schema: JSONSchemaType<T>,
     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<void> {
-            if (chargingStation.getEnableStatistics()) {
+            if (chargingStation.getEnableStatistics() === true) {
               chargingStation.performanceStatistics.addRequestStatistic(
                 commandName,
                 MessageType.CALL_RESULT_MESSAGE
index 3faa4351e7ef8867096c2844ef5d243110dcfb0d..91b1499676b01f3b1e7583c0c385490c70e78ef8 100644 (file)
@@ -35,7 +35,7 @@ export default abstract class OCPPResponseService {
     schema: JSONSchemaType<T>,
     payload: T
   ): boolean {
-    if (!chargingStation.getPayloadSchemaValidation()) {
+    if (chargingStation.getPayloadSchemaValidation() === false) {
       return true;
     }
     const validate = this.ajv.compile(schema);