diff --git a/packages/archival/src/aws-s3/import-archive-data.provider.ts b/packages/archival/src/aws-s3/import-archive-data.provider.ts index 0b0fedcebe..deb235bc46 100644 --- a/packages/archival/src/aws-s3/import-archive-data.provider.ts +++ b/packages/archival/src/aws-s3/import-archive-data.provider.ts @@ -6,6 +6,7 @@ import { } from '@loopback/core'; import {AnyObject} from '@loopback/repository'; import {HttpErrors} from '@loopback/rest'; +// eslint-disable-next-line @typescript-eslint/naming-convention import AWS from 'aws-sdk'; import {ImportDataExternalSystem} from '../types'; @@ -32,10 +33,10 @@ export class ImportArchiveDataProvider Bucket: process.env.AWS_S3_BUCKET_NAME as string, Key: fileName, }; - let data; + let s3Response; try { - data = await s3.getObject(params).promise(); - const csvData = data.Body!.toString('utf-8'); + s3Response = await s3.getObject(params).promise(); + const csvData = s3Response.Body!.toString('utf-8'); const jsonArray: AnyObject[] = await new Promise((resolve, reject) => { const results: AnyObject[] = []; @@ -48,6 +49,7 @@ export class ImportArchiveDataProvider const headers = Object.keys(jsonArray[0]); for (const entry of jsonArray) { for (const key of headers) { + //sonarignore:start const value = entry[key]; if (value === '') { entry[key] = null; @@ -58,6 +60,7 @@ export class ImportArchiveDataProvider entry[key] = new Date(value); } else entry[key] = value; } + //sonarignore:end } return jsonArray; } catch (error) { diff --git a/packages/archival/src/mixins/archival.mixin.ts b/packages/archival/src/mixins/archival.mixin.ts index 61e109bf06..3c489b0290 100644 --- a/packages/archival/src/mixins/archival.mixin.ts +++ b/packages/archival/src/mixins/archival.mixin.ts @@ -24,6 +24,7 @@ import { User, } from '../types'; +// NOSONAR - ignore camelCase naming convention export function ArchivalRepositoryMixin< T extends UserModifiableEntity, ID, diff --git a/packages/archival/src/services/import-archived-data.service.ts b/packages/archival/src/services/import-archived-data.service.ts index 8d78296bb0..8502997a35 100644 --- a/packages/archival/src/services/import-archived-data.service.ts +++ b/packages/archival/src/services/import-archived-data.service.ts @@ -28,7 +28,8 @@ import { @injectable({scope: BindingScope.TRANSIENT}) export class ImportArchivedDataService { - repo: AnyObject; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + repo: any; constructor( @repository(JobDetailsRepository) public jobDetailsRepo: JobDetailsRepository, @@ -59,7 +60,6 @@ export class ImportArchivedDataService { const jobDetails = await this.jobDetailsRepo.findById(jobId); const modelName = jobDetails.entity; const filter = jobDetails.filterInquired; - const importData: AnyObject = {}; const archiveFilter: Filter = await this.buildWhereConditionService.buildConditionForFetch( @@ -69,7 +69,7 @@ export class ImportArchivedDataService { const archivedEntries = await this.archivalMappingRepo.find(archiveFilter); - let data: AnyObject[] = []; + const data: AnyObject[] = []; for (const entry of archivedEntries) { const fileContent = await this.importArchiveData(entry.key); @@ -105,26 +105,29 @@ export class ImportArchivedDataService { status: JobStatus.SUCCESS, result: JSON.stringify(allRecords), }); - this.processImportedData(allRecords); + await this.processImportedData(allRecords); } - async getFilteredData() {} - // sonarignore:start private async getRepositoryByModelName( modelName: string, + // eslint-disable-next-line @typescript-eslint/no-explicit-any ): Promise | undefined> { // Find all bindings with keys matching 'repositories.*' const repositoryBindings = + // eslint-disable-next-line @typescript-eslint/no-explicit-any this.context.find>('repositories.*'); // Iterate through the bindings to find the matching repository for (const binding of repositoryBindings) { - const repository = await this.context.get< + const repoName = await this.context.get< + // eslint-disable-next-line @typescript-eslint/no-explicit-any DefaultCrudRepository + // eslint-disable-next-line @typescript-eslint/no-explicit-any >(binding.key as unknown as BindingKey>); - if (repository.entityClass.name === modelName) { - return repository as DefaultCrudRepository; + if (repoName.entityClass.name === modelName) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return repoName as DefaultCrudRepository; } } // sonarignore:end diff --git a/packages/archival/src/types.ts b/packages/archival/src/types.ts index 92c4ee2360..25fc72add1 100644 --- a/packages/archival/src/types.ts +++ b/packages/archival/src/types.ts @@ -25,7 +25,9 @@ export type MixinBaseClass = AbstractConstructor; export type ArchiveMixinBase< T extends UserModifiableEntity, + // eslint-disable-next-line @typescript-eslint/no-unused-vars ID, + // eslint-disable-next-line @typescript-eslint/no-unused-vars Relations, > = MixinBaseClass<{ entityClass: typeof UserModifiableEntity & {