Skip to content

Commit

Permalink
Remove unused vars
Browse files Browse the repository at this point in the history
Remove undefined eslint rules
  • Loading branch information
robbcocco committed Jan 31, 2025
1 parent 85274dc commit f01186f
Show file tree
Hide file tree
Showing 14 changed files with 61 additions and 61 deletions.
7 changes: 4 additions & 3 deletions src/adapters/pnFetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -459,7 +460,7 @@ export const redirectAttachment =
),
),
),
E.getOrElse((_) =>
E.getOrElse(() =>
pipe(
attachment.retryAfter,
t.number.decode,
Expand Down
8 changes: 4 additions & 4 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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),
);

Expand All @@ -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;
},
Expand Down Expand Up @@ -920,7 +920,7 @@ function registerAPIRoutes(
`${basePath}/services`,
bearerSessionTokenAuth,
toExpressHandler(
(_) => Promise.resolve(ResponseSuccessJson({ items: [] })),
() => Promise.resolve(ResponseSuccessJson({ items: [] })),
servicesController,
),
);
Expand Down
4 changes: 2 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/authenticationController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
Expand Down
12 changes: 5 additions & 7 deletions src/controllers/cgnOperatorSearchController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ export default class CgnOperatorSearchController {
| IResponseErrorValidation
| IResponseSuccessJson<CountResult>
> =>
withUserFromRequest(req, async (_) =>
this.cgnOperatorSearchService.count(),
);
withUserFromRequest(req, async () => this.cgnOperatorSearchService.count());

/**
* Get a discount bucket code by discount identifier.
Expand Down Expand Up @@ -141,7 +139,7 @@ export default class CgnOperatorSearchController {
| IResponseErrorValidation
| IResponseSuccessJson<OfflineMerchants>
> =>
withUserFromRequest(req, async (_) =>
withUserFromRequest(req, async () =>
withValidatedOrValidationError(
OfflineMerchantSearchRequest.decode(req.body),
(offlineSearchRequest) =>
Expand All @@ -163,7 +161,7 @@ export default class CgnOperatorSearchController {
| IResponseErrorValidation
| IResponseSuccessJson<OnlineMerchants>
> =>
withUserFromRequest(req, async (_) =>
withUserFromRequest(req, async () =>
withValidatedOrValidationError(
OnlineMerchantSearchRequest.decode(req.body),
(onlineSearchRequest) =>
Expand All @@ -182,7 +180,7 @@ export default class CgnOperatorSearchController {
| IResponseErrorValidation
| IResponseSuccessJson<PublishedProductCategoriesResult>
> =>
withUserFromRequest(req, async (_) =>
withUserFromRequest(req, async () =>
withValidatedOrValidationError(
GetPublishedCategoriesParameters.decode(req.query),
(params) =>
Expand All @@ -201,7 +199,7 @@ export default class CgnOperatorSearchController {
| IResponseErrorValidation
| IResponseSuccessJson<SearchResult>
> =>
withUserFromRequest(req, async (_) =>
withUserFromRequest(req, async () =>
withValidatedOrValidationError(
SearchRequest.decode(req.body),
(searchRequest) => this.cgnOperatorSearchService.search(searchRequest),
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/ioSignController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
),
Expand Down
8 changes: 4 additions & 4 deletions src/controllers/messagesController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export default class MessagesController {
user.fiscal_code,
lollipopHeaders,
),
TE.mapLeft((_) =>
TE.mapLeft(() =>
ResponseErrorInternal(
"Error extracting lollipop locals",
),
Expand Down Expand Up @@ -203,7 +203,7 @@ export default class MessagesController {
remoteContentConfiguration,
lollipopLocals as LollipopLocalsType,
),
(_) =>
() =>
ResponseErrorInternal(
"Error getting message from third party service",
),
Expand Down Expand Up @@ -243,7 +243,7 @@ export default class MessagesController {
remoteContentConfiguration,
lollipopLocals as LollipopLocalsType,
),
(_) =>
() =>
ResponseErrorInternal(
"Error getting attachment from third party service",
),
Expand Down Expand Up @@ -280,7 +280,7 @@ export default class MessagesController {
remoteContentConfiguration,
lollipopLocals as LollipopLocalsType,
),
(_) =>
() =>
ResponseErrorInternal(
"Error getting preconditions from third party service",
),
Expand Down
52 changes: 25 additions & 27 deletions src/controllers/notificationController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,33 +90,31 @@ export default class NotificationController {
req: express.Request,
): Promise<IResponseErrorValidation | IResponseSuccessJson<SuccessResponse>> {
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" });
},
),
),
);
}
Expand Down
2 changes: 2 additions & 0 deletions src/controllers/serviceAppBackendController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<IResponseErrorInternal | IResponseSuccessJson<Institutions>> =>
this.servicesAppBackendService.getFeaturedInstitutions();

public readonly getFeaturedServices = async (
// eslint-disable-next-line @typescript-eslint/no-unused-vars
_req: express.Request,
): Promise<IResponseErrorInternal | IResponseSuccessJson<FeaturedServices>> =>
this.servicesAppBackendService.getFeaturedServices();
Expand Down
16 changes: 8 additions & 8 deletions src/controllers/sessionLockController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)(),
);
Expand Down Expand Up @@ -314,15 +314,15 @@ 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,
() =>
ResponseErrorConflict(
"Another user authentication lock has already been applied",
),
),
TE.chainW((_) =>
TE.chainW(() =>
pipe(
AP.sequenceT(TE.ApplicativeSeq)(
// clear session data
Expand All @@ -339,7 +339,7 @@ export default class SessionLockController {
TE.mapLeft((err) => ResponseErrorInternal(err.message)),
),
),
TE.map((_) => ResponseNoContent()),
TE.map(() => ResponseNoContent()),
TE.toUnion,
)(),
),
Expand Down Expand Up @@ -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,
)(),
);
Expand Down Expand Up @@ -414,7 +414,7 @@ export default class SessionLockController {
this.authenticationLockService.getUserAuthenticationLockData(
fiscalCode,
),
TE.mapLeft((_) =>
TE.mapLeft(() =>
ResponseErrorInternal(ERROR_CHECK_USER_AUTH_LOCK),
),
),
Expand All @@ -430,7 +430,7 @@ export default class SessionLockController {
: // User auth is NOT locked
TE.of(true),
),
TE.map((_) => ResponseNoContent()),
TE.map(() => ResponseNoContent()),
TE.toUnion,
)(),
),
Expand Down Expand Up @@ -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,
)();

Expand Down
4 changes: 2 additions & 2 deletions src/services/authenticationLockService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
);

/**
Expand Down
1 change: 1 addition & 0 deletions src/services/bonusService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default class BonusService {
*
*/
public readonly getAllBonusActivations = (
// eslint-disable-next-line @typescript-eslint/no-unused-vars
_: User,
): Promise<
| IResponseErrorInternal
Expand Down
1 change: 0 additions & 1 deletion src/services/ioWalletService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable sonarjs/no-identical-functions */
/**
* This service interacts with the IO Wallet API
*/
Expand Down
1 change: 1 addition & 0 deletions src/services/newMessagesService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit f01186f

Please sign in to comment.