Skip to content
Snippets Groups Projects
Commit 41fb3f8d authored by michael.minelli's avatar michael.minelli
Browse files

Sonar => Remove code smells

parent cc047073
No related branches found
No related tags found
No related merge requests found
Pipeline #31633 passed
......@@ -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
......@@ -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);
});
});
......
......@@ -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();
});
......
......@@ -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();
});
}
......
......@@ -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;
......
......@@ -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() });
......
......@@ -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();
});
});
......
Subproject commit 771f8cd079b39ec4050c5ece024dc4d70f342529
Subproject commit c2afa861bf6306ddec79ffd465a4c7b0edcd3453
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment