From 41fb3f8df3ca9afd3274a75c77735cd5da5efe6e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C3=ABl=20Minelli?= <git@minelli.me>
Date: Fri, 19 Apr 2024 22:50:42 +0200
Subject: [PATCH] Sonar => Remove code smells

---
 ExpressAPI/eslint.config.mjs                            | 1 +
 ExpressAPI/src/controllers/Session.ts                   | 4 ++--
 ExpressAPI/src/express/API.ts                           | 2 +-
 ExpressAPI/src/helpers/DojoValidators.ts                | 2 +-
 ExpressAPI/src/middlewares/ParamsCallbackManager.ts     | 2 +-
 ExpressAPI/src/middlewares/ParamsValidatorMiddleware.ts | 2 +-
 ExpressAPI/src/middlewares/SessionMiddleware.ts         | 2 +-
 ExpressAPI/src/shared                                   | 2 +-
 8 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/ExpressAPI/eslint.config.mjs b/ExpressAPI/eslint.config.mjs
index 4d80e1f..67e9053 100644
--- a/ExpressAPI/eslint.config.mjs
+++ b/ExpressAPI/eslint.config.mjs
@@ -20,5 +20,6 @@ export default tseslint.config({
                                        '@typescript-eslint/no-unsafe-member-access': 'off',
                                        '@typescript-eslint/require-await': 'off',
                                        '@typescript-eslint/restrict-template-expressions': 'off',
+                                       '@typescript-eslint/no-floating-promises': 'off',
                                    }
                                });
\ No newline at end of file
diff --git a/ExpressAPI/src/controllers/Session.ts b/ExpressAPI/src/controllers/Session.ts
index d3063ea..d9b03d6 100644
--- a/ExpressAPI/src/controllers/Session.ts
+++ b/ExpressAPI/src/controllers/Session.ts
@@ -66,8 +66,8 @@ class Session {
      */
     sendResponse(res: express.Response | undefined, code: number, data?: unknown, descriptionOverride?: string, internalCode?: number) {
         if ( res ) {
-            void Promise.resolve(data).then((toReturn: unknown) => {
-                void this.getResponse(internalCode ?? code, toReturn, descriptionOverride).then(response => {
+            Promise.resolve(data).then((toReturn: unknown) => {
+                this.getResponse(internalCode ?? code, toReturn, descriptionOverride).then(response => {
                     res.status(code).json(response);
                 });
             });
diff --git a/ExpressAPI/src/express/API.ts b/ExpressAPI/src/express/API.ts
index 7535203..c8df2c0 100644
--- a/ExpressAPI/src/express/API.ts
+++ b/ExpressAPI/src/express/API.ts
@@ -46,7 +46,7 @@ class API implements WorkerTask {
         this.backend.use(compression()); //Compress responses
 
         this.backend.use((_req, res, next) => {
-            void DojoCliVersionHelper.getLatestVersion().then((latestVersion) => {
+            DojoCliVersionHelper.getLatestVersion().then(latestVersion => {
                 res.header('dojocli-latest-version', latestVersion);
                 next();
             });
diff --git a/ExpressAPI/src/helpers/DojoValidators.ts b/ExpressAPI/src/helpers/DojoValidators.ts
index c00cbca..0cd04ce 100644
--- a/ExpressAPI/src/helpers/DojoValidators.ts
+++ b/ExpressAPI/src/helpers/DojoValidators.ts
@@ -62,7 +62,7 @@ class DojoValidators {
                                                                           return new Promise((resolve, reject) => {
                                                                               const template = this.getParamValue(req, path) as string;
                                                                               if ( template ) {
-                                                                                  void GitlabManager.checkTemplateAccess(template, req).then(templateAccess => {
+                                                                                  GitlabManager.checkTemplateAccess(template, req).then(templateAccess => {
                                                                                       templateAccess ? resolve(true) : reject();
                                                                                   });
                                                                               }
diff --git a/ExpressAPI/src/middlewares/ParamsCallbackManager.ts b/ExpressAPI/src/middlewares/ParamsCallbackManager.ts
index 576bcb1..a1836d1 100644
--- a/ExpressAPI/src/middlewares/ParamsCallbackManager.ts
+++ b/ExpressAPI/src/middlewares/ParamsCallbackManager.ts
@@ -11,7 +11,7 @@ type GetFunction = (id: string | number, ...args: Array<unknown>) => Promise<unk
 class ParamsCallbackManager {
     protected listenParam(paramName: string, backend: Express, getFunction: GetFunction, args: Array<unknown>, indexName: string) {
         backend.param(paramName, (req: express.Request, res: express.Response, next: express.NextFunction, id: string | number) => {
-            void getFunction(id, ...args).then(result => {
+            getFunction(id, ...args).then(result => {
                 if ( result ) {
                     this.initBoundParams(req);
                     (req.boundParams as Record<string, unknown>)[indexName] = result;
diff --git a/ExpressAPI/src/middlewares/ParamsValidatorMiddleware.ts b/ExpressAPI/src/middlewares/ParamsValidatorMiddleware.ts
index 1d1445d..b42408c 100644
--- a/ExpressAPI/src/middlewares/ParamsValidatorMiddleware.ts
+++ b/ExpressAPI/src/middlewares/ParamsValidatorMiddleware.ts
@@ -10,7 +10,7 @@ class ParamsValidatorMiddleware {
                 validations = ExpressValidator.checkSchema(validations);
             }
 
-            void Promise.all(validations.map(validation => validation.run(req))).then(() => {
+            Promise.all(validations.map(validation => validation.run(req))).then(() => {
                 const errors = ExpressValidator.validationResult(req);
                 if ( !errors.isEmpty() ) {
                     req.session.sendResponse(res, StatusCodes.BAD_REQUEST, { errors: errors.array() });
diff --git a/ExpressAPI/src/middlewares/SessionMiddleware.ts b/ExpressAPI/src/middlewares/SessionMiddleware.ts
index ceb9ada..116c24b 100644
--- a/ExpressAPI/src/middlewares/SessionMiddleware.ts
+++ b/ExpressAPI/src/middlewares/SessionMiddleware.ts
@@ -7,7 +7,7 @@ class SessionMiddleware {
     registerOnBackend(backend: Express) {
         backend.use((req: express.Request, res: express.Response, next: express.NextFunction) => {
             req.session = new Session();
-            void req.session.initSession(req, res).then(() => {
+            req.session.initSession(req, res).then(() => {
                 next();
             });
         });
diff --git a/ExpressAPI/src/shared b/ExpressAPI/src/shared
index 771f8cd..c2afa86 160000
--- a/ExpressAPI/src/shared
+++ b/ExpressAPI/src/shared
@@ -1 +1 @@
-Subproject commit 771f8cd079b39ec4050c5ece024dc4d70f342529
+Subproject commit c2afa861bf6306ddec79ffd465a4c7b0edcd3453
-- 
GitLab