Implemented changes suggested by Deepsource.io

Signed-off-by: AaronvDiepen <aaronvdiepen@gmail.com>
This commit is contained in:
AaronvDiepen
2022-03-17 11:57:58 +01:00
parent 9f8d2714f0
commit 99f9406a2d
11 changed files with 24 additions and 25 deletions
@@ -30,7 +30,7 @@ describe('BitbucketRepositoryParser', () => {
presence: 'optional',
}),
];
const actual = await defaultRepositoryParser({
const actual = defaultRepositoryParser({
target: `${browseUrl}${path}`,
});
@@ -34,17 +34,16 @@ export type BitbucketRepositoryParser = (options: {
logger: Logger;
}) => AsyncIterable<CatalogProcessorResult>;
export const defaultRepositoryParser =
async function* defaultRepositoryParser(options: {
target: string;
presence?: 'optional' | 'required';
}) {
yield processingResult.location({
type: 'url',
target: options.target,
// Not all locations may actually exist, since the user defined them as a wildcard pattern.
// Thus, we emit them as optional and let the downstream processor find them while not outputting
// an error if it couldn't.
presence: options.presence ?? 'optional',
});
};
export function* defaultRepositoryParser(options: {
target: string;
presence?: 'optional' | 'required';
}) {
yield processingResult.location({
type: 'url',
target: options.target,
// Not all locations may actually exist, since the user defined them as a wildcard pattern.
// Thus, we emit them as optional and let the downstream processor find them while not outputting
// an error if it couldn't.
presence: options.presence ?? 'optional',
});
}
@@ -144,7 +144,7 @@ describe('FactRetrieverEngine', () => {
engine.schedule();
const job: any = engine.getJob('test-factretriever');
job.triggerScheduledJobNow();
expect(job.cadence!!).toEqual(cadence);
expect(job.cadence!).toEqual(cadence);
expect(testFactRetriever.handler).toHaveBeenCalledWith(
expect.objectContaining({ entityFilter: testFactRetriever.entityFilter }),
);
@@ -53,7 +53,7 @@ export const entityMetadataFactRetriever: FactRetriever = {
return entities.items.map((entity: Entity) => {
return {
entity: {
namespace: entity.metadata.namespace!!,
namespace: entity.metadata.namespace!,
kind: entity.kind,
name: entity.metadata.name,
},
@@ -51,7 +51,7 @@ export const entityOwnershipFactRetriever: FactRetriever = {
return entities.items.map((entity: Entity) => {
return {
entity: {
namespace: entity.metadata.namespace!!,
namespace: entity.metadata.namespace!,
kind: entity.kind,
name: entity.metadata.name,
},
@@ -49,7 +49,7 @@ export const techdocsFactRetriever: FactRetriever = {
return entities.items.map((entity: Entity) => {
return {
entity: {
namespace: entity.metadata.namespace!!,
namespace: entity.metadata.namespace!,
kind: entity.kind,
name: entity.metadata.name,
},
@@ -62,7 +62,7 @@ export class TechInsightsDatabase implements TechInsightsStore {
return Object.values(groupedSchemas)
.map(schemas => {
const sorted = rsort(schemas.map(it => it.version));
return schemas.find(it => it.version === sorted[0])!!;
return schemas.find(it => it.version === sorted[0])!;
})
.map((it: RawDbFactSchemaRow) => ({
...omit(it, 'schema'),
@@ -188,7 +188,7 @@ export class TechInsightsDatabase implements TechInsightsStore {
throw new Error(`No schema found for ${id}. `);
}
const sorted = rsort(existingSchemas.map(it => it.version));
return existingSchemas.find(it => it.version === sorted[0])!!;
return existingSchemas.find(it => it.version === sorted[0])!;
}
private async deleteExpiredFactsByDate(