diff --git a/src/adapters/pnFetch.ts b/src/adapters/pnFetch.ts index ac7d92d4d..81b10ea9f 100644 --- a/src/adapters/pnFetch.ts +++ b/src/adapters/pnFetch.ts @@ -196,7 +196,7 @@ export const redirectPrecondition = ThirdPartyPreconditionUrl.decode, E.mapLeft(errorsToError), TE.fromEither, - eventLog.taskEither.info((_) => [ + eventLog.taskEither.info(() => [ `pn.precondition.call`, { locals: lollipopLocals @@ -253,7 +253,7 @@ export const redirectMessages = ThirdPartyMessagesUrl.decode, E.mapLeft(errorsToError), TE.fromEither, - eventLog.taskEither.info((_) => [ + eventLog.taskEither.info(() => [ `pn.notification.call`, { locals: lollipopLocals @@ -397,6 +397,7 @@ export const redirectAttachment = ThirdPartyAttachmentUrl.decode, E.mapLeft(errorsToError), TE.fromEither, + // eslint-disable-next-line @typescript-eslint/no-unused-vars TE.chain(([_id, getAttachmentUrl]) => match(getAttachmentUrl) .when( @@ -459,7 +460,7 @@ export const redirectAttachment = ), ), ), - E.getOrElse((_) => + E.getOrElse(() => pipe( attachment.retryAfter, t.number.decode, diff --git a/src/app.ts b/src/app.ts index d9a38af9a..2233f8dde 100644 --- a/src/app.ts +++ b/src/app.ts @@ -167,7 +167,6 @@ export interface IAppFactoryParameters { readonly env: NodeEnvironment; } -// eslint-disable-next-line max-lines-per-function, sonarjs/cognitive-complexity export async function newApp({ APIBasePath, BonusAPIBasePath, @@ -253,7 +252,7 @@ export async function newApp({ // Adds the user fiscal code // we take only the first 6 characters of the fiscal code - morgan.token("fiscal_code_short", (req: express.Request, _) => + morgan.token("fiscal_code_short", (req: express.Request) => pipe( req.user, User.decode, @@ -266,7 +265,7 @@ export async function newApp({ originalUrl.replace(/([?&]token=|[?&]access_token=)([^&]*)/g, "$1REDACTED"); // Obfuscate token in url on morgan logs - morgan.token("obfuscated_url", (req: express.Request, _) => + morgan.token("obfuscated_url", (req: express.Request) => obfuscateToken(req.originalUrl), ); @@ -282,6 +281,7 @@ export async function newApp({ // Parse the incoming request body. This is needed by Passport spid strategy. app.use( bodyParser.json({ + // eslint-disable-next-line @typescript-eslint/no-unused-vars verify: (_req, res: express.Response, buf, _encoding: BufferEncoding) => { res.locals.body = buf; }, @@ -920,7 +920,7 @@ function registerAPIRoutes( `${basePath}/services`, bearerSessionTokenAuth, toExpressHandler( - (_) => Promise.resolve(ResponseSuccessJson({ items: [] })), + () => Promise.resolve(ResponseSuccessJson({ items: [] })), servicesController, ), ); diff --git a/src/config.ts b/src/config.ts index c03dead32..773de69f2 100644 --- a/src/config.ts +++ b/src/config.ts @@ -521,7 +521,7 @@ export const PN_CONFIGURATION_ID = pipe( export const FF_ROUTING_PUSH_NOTIF = pipe( process.env.FF_ROUTING_PUSH_NOTIF, FeatureFlag.decode, - E.getOrElse((_) => FeatureFlagEnum.NONE), + E.getOrElse(() => FeatureFlagEnum.NONE), ); export const FF_ROUTING_PUSH_NOTIF_BETA_TESTER_SHA_LIST = pipe( @@ -539,7 +539,7 @@ export const FF_ROUTING_PUSH_NOTIF_BETA_TESTER_SHA_LIST = pipe( export const FF_ROUTING_PUSH_NOTIF_CANARY_SHA_USERS_REGEX = pipe( process.env.FF_ROUTING_PUSH_NOTIF_CANARY_SHA_USERS_REGEX, NonEmptyString.decode, - E.getOrElse((_) => "XYZ" as NonEmptyString), + E.getOrElse(() => "XYZ" as NonEmptyString), ); // UNIQUE EMAIL ENFORCEMENT variables diff --git a/src/controllers/authenticationController.ts b/src/controllers/authenticationController.ts index 003bfd23c..7395b633f 100644 --- a/src/controllers/authenticationController.ts +++ b/src/controllers/authenticationController.ts @@ -32,14 +32,14 @@ export const getUserIdentity: ( pipe( user, UserIdentity.decode, - E.mapLeft((_) => + E.mapLeft(() => ResponseErrorInternal("Unexpected User Identity data format."), ), E.map((_) => pipe( _, exactUserIdentityDecode, - E.mapLeft((_1) => ResponseErrorInternal("Exact decode failed.")), + E.mapLeft(() => ResponseErrorInternal("Exact decode failed.")), E.map(ResponseSuccessJson), E.toUnion, ), diff --git a/src/controllers/cgnOperatorSearchController.ts b/src/controllers/cgnOperatorSearchController.ts index de2d5e880..1e4001d32 100644 --- a/src/controllers/cgnOperatorSearchController.ts +++ b/src/controllers/cgnOperatorSearchController.ts @@ -76,9 +76,7 @@ export default class CgnOperatorSearchController { | IResponseErrorValidation | IResponseSuccessJson > => - withUserFromRequest(req, async (_) => - this.cgnOperatorSearchService.count(), - ); + withUserFromRequest(req, async () => this.cgnOperatorSearchService.count()); /** * Get a discount bucket code by discount identifier. @@ -141,7 +139,7 @@ export default class CgnOperatorSearchController { | IResponseErrorValidation | IResponseSuccessJson > => - withUserFromRequest(req, async (_) => + withUserFromRequest(req, async () => withValidatedOrValidationError( OfflineMerchantSearchRequest.decode(req.body), (offlineSearchRequest) => @@ -163,7 +161,7 @@ export default class CgnOperatorSearchController { | IResponseErrorValidation | IResponseSuccessJson > => - withUserFromRequest(req, async (_) => + withUserFromRequest(req, async () => withValidatedOrValidationError( OnlineMerchantSearchRequest.decode(req.body), (onlineSearchRequest) => @@ -182,7 +180,7 @@ export default class CgnOperatorSearchController { | IResponseErrorValidation | IResponseSuccessJson > => - withUserFromRequest(req, async (_) => + withUserFromRequest(req, async () => withValidatedOrValidationError( GetPublishedCategoriesParameters.decode(req.query), (params) => @@ -201,7 +199,7 @@ export default class CgnOperatorSearchController { | IResponseErrorValidation | IResponseSuccessJson > => - withUserFromRequest(req, async (_) => + withUserFromRequest(req, async () => withValidatedOrValidationError( SearchRequest.decode(req.body), (searchRequest) => this.cgnOperatorSearchService.search(searchRequest), diff --git a/src/controllers/ioSignController.ts b/src/controllers/ioSignController.ts index 0389b9527..5ee800466 100644 --- a/src/controllers/ioSignController.ts +++ b/src/controllers/ioSignController.ts @@ -265,7 +265,7 @@ export default class IoSignController { req.params.id, Id.decode, TE.fromEither, - TE.mapLeft((_) => + TE.mapLeft(() => ResponseErrorInternal( `Error validating the signature request id`, ), diff --git a/src/controllers/messagesController.ts b/src/controllers/messagesController.ts index 8fa55a485..af07c7850 100644 --- a/src/controllers/messagesController.ts +++ b/src/controllers/messagesController.ts @@ -115,7 +115,7 @@ export default class MessagesController { user.fiscal_code, lollipopHeaders, ), - TE.mapLeft((_) => + TE.mapLeft(() => ResponseErrorInternal( "Error extracting lollipop locals", ), @@ -203,7 +203,7 @@ export default class MessagesController { remoteContentConfiguration, lollipopLocals as LollipopLocalsType, ), - (_) => + () => ResponseErrorInternal( "Error getting message from third party service", ), @@ -243,7 +243,7 @@ export default class MessagesController { remoteContentConfiguration, lollipopLocals as LollipopLocalsType, ), - (_) => + () => ResponseErrorInternal( "Error getting attachment from third party service", ), @@ -280,7 +280,7 @@ export default class MessagesController { remoteContentConfiguration, lollipopLocals as LollipopLocalsType, ), - (_) => + () => ResponseErrorInternal( "Error getting preconditions from third party service", ), diff --git a/src/controllers/notificationController.ts b/src/controllers/notificationController.ts index d48a7a51e..028f2159a 100644 --- a/src/controllers/notificationController.ts +++ b/src/controllers/notificationController.ts @@ -90,33 +90,31 @@ export default class NotificationController { req: express.Request, ): Promise> { return withUserFromRequest(req, async (user) => - withValidatedOrValidationError( - InstallationID.decode(req.params.id), - (_) => - withValidatedOrValidationError( - Installation.decode(req.body), - (installation) => { - // async fire & forget - // On login, we do a deleteInstallation to prevent a device to be associated with a previous user, which might be a different one - // We have empirical evidence that such deleteInstallation is processed after the createOrUpdateInstallation, - // so that the installation we are recording after login is lost - // The correct order of execution must be enforced by the processing notifications service. - // Anyway, to quickly mitigate the disservice to our users, we apply this temporary workaround - delay(10000 as Millisecond) - .then(() => - this.notificationServiceFactory( - user.fiscal_code, - ).createOrUpdateInstallation(user.fiscal_code, installation), - ) - .catch((err) => { - log.error( - "Cannot create installation: %s", - JSON.stringify(err), - ); - }); - return ResponseSuccessJson({ message: "ok" }); - }, - ), + withValidatedOrValidationError(InstallationID.decode(req.params.id), () => + withValidatedOrValidationError( + Installation.decode(req.body), + (installation) => { + // async fire & forget + // On login, we do a deleteInstallation to prevent a device to be associated with a previous user, which might be a different one + // We have empirical evidence that such deleteInstallation is processed after the createOrUpdateInstallation, + // so that the installation we are recording after login is lost + // The correct order of execution must be enforced by the processing notifications service. + // Anyway, to quickly mitigate the disservice to our users, we apply this temporary workaround + delay(10000 as Millisecond) + .then(() => + this.notificationServiceFactory( + user.fiscal_code, + ).createOrUpdateInstallation(user.fiscal_code, installation), + ) + .catch((err) => { + log.error( + "Cannot create installation: %s", + JSON.stringify(err), + ); + }); + return ResponseSuccessJson({ message: "ok" }); + }, + ), ), ); } diff --git a/src/controllers/serviceAppBackendController.ts b/src/controllers/serviceAppBackendController.ts index 816ea766c..572bf5216 100644 --- a/src/controllers/serviceAppBackendController.ts +++ b/src/controllers/serviceAppBackendController.ts @@ -72,11 +72,13 @@ export default class ServicesAppBackendController { ); public readonly getFeaturedInstitutions = async ( + // eslint-disable-next-line @typescript-eslint/no-unused-vars _req: express.Request, ): Promise> => this.servicesAppBackendService.getFeaturedInstitutions(); public readonly getFeaturedServices = async ( + // eslint-disable-next-line @typescript-eslint/no-unused-vars _req: express.Request, ): Promise> => this.servicesAppBackendService.getFeaturedServices(); diff --git a/src/controllers/sessionLockController.ts b/src/controllers/sessionLockController.ts index 0a1ca3e1f..89c7061d0 100644 --- a/src/controllers/sessionLockController.ts +++ b/src/controllers/sessionLockController.ts @@ -201,7 +201,7 @@ export default class SessionLockController { this.buildInvalidateUserSessionTask(fiscalCode), ), TE.mapLeft((err) => ResponseErrorInternal(err.message)), - TE.map((_) => ResponseSuccessJson({ message: "ok" })), + TE.map(() => ResponseSuccessJson({ message: "ok" })), TE.toUnion, )(), ); @@ -314,7 +314,7 @@ export default class SessionLockController { pipe( // lock the authentication this.authenticationLockService.isUserAuthenticationLocked(fiscalCode), - TE.mapLeft((_) => ResponseErrorInternal(ERROR_CHECK_USER_AUTH_LOCK)), + TE.mapLeft(() => ResponseErrorInternal(ERROR_CHECK_USER_AUTH_LOCK)), TE.filterOrElseW( (isUserAuthenticationLocked) => !isUserAuthenticationLocked, () => @@ -322,7 +322,7 @@ export default class SessionLockController { "Another user authentication lock has already been applied", ), ), - TE.chainW((_) => + TE.chainW(() => pipe( AP.sequenceT(TE.ApplicativeSeq)( // clear session data @@ -339,7 +339,7 @@ export default class SessionLockController { TE.mapLeft((err) => ResponseErrorInternal(err.message)), ), ), - TE.map((_) => ResponseNoContent()), + TE.map(() => ResponseNoContent()), TE.toUnion, )(), ), @@ -378,7 +378,7 @@ export default class SessionLockController { ), ), TE.mapLeft((err) => ResponseErrorInternal(err.message)), - TE.map((_) => ResponseSuccessJson({ message: "ok" })), + TE.map(() => ResponseSuccessJson({ message: "ok" })), TE.toUnion, )(), ); @@ -414,7 +414,7 @@ export default class SessionLockController { this.authenticationLockService.getUserAuthenticationLockData( fiscalCode, ), - TE.mapLeft((_) => + TE.mapLeft(() => ResponseErrorInternal(ERROR_CHECK_USER_AUTH_LOCK), ), ), @@ -430,7 +430,7 @@ export default class SessionLockController { : // User auth is NOT locked TE.of(true), ), - TE.map((_) => ResponseNoContent()), + TE.map(() => ResponseNoContent()), TE.toUnion, )(), ), @@ -468,7 +468,7 @@ export default class SessionLockController { TE.mapLeft((err) => ResponseErrorInternal(err.message)), ), ), - TE.map((_) => ResponseSuccessJson({ message: "ok" })), + TE.map(() => ResponseSuccessJson({ message: "ok" })), TE.toUnion, )(); diff --git a/src/services/authenticationLockService.ts b/src/services/authenticationLockService.ts index 78631735a..f0534582c 100644 --- a/src/services/authenticationLockService.ts +++ b/src/services/authenticationLockService.ts @@ -88,9 +88,9 @@ export default class AuthenticationLockService { rowKey: unlockCode, }), - (_) => new Error("Something went wrong creating the record"), + () => new Error("Something went wrong creating the record"), ), - TE.map((_) => true as const), + TE.map(() => true as const), ); /** diff --git a/src/services/bonusService.ts b/src/services/bonusService.ts index 7e5f647b2..bd818a1e5 100644 --- a/src/services/bonusService.ts +++ b/src/services/bonusService.ts @@ -40,6 +40,7 @@ export default class BonusService { * */ public readonly getAllBonusActivations = ( + // eslint-disable-next-line @typescript-eslint/no-unused-vars _: User, ): Promise< | IResponseErrorInternal diff --git a/src/services/ioWalletService.ts b/src/services/ioWalletService.ts index fbf021cc0..ea763d0dc 100644 --- a/src/services/ioWalletService.ts +++ b/src/services/ioWalletService.ts @@ -1,4 +1,3 @@ -/* eslint-disable sonarjs/no-identical-functions */ /** * This service interacts with the IO Wallet API */ diff --git a/src/services/newMessagesService.ts b/src/services/newMessagesService.ts index 60875c9c8..104ec8b2c 100644 --- a/src/services/newMessagesService.ts +++ b/src/services/newMessagesService.ts @@ -167,6 +167,7 @@ export default class NewMessagesService { case 500: return ResponseErrorInternal(ERROR_MESSAGE_500); case 503: + // eslint-disable-next-line no-case-declarations const retryAfter = response.headers["Retry-After"] ?? "10"; return ResponseErrorServiceTemporarilyUnavailable( ERROR_MESSAGE_503,