Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement code changes as suggested by analysis tools #10287

Merged
merged 3 commits into from
Mar 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/silent-bobcats-matter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@backstage/cli': patch
'@backstage/config-loader': patch
'@backstage/core-app-api': patch
'@backstage/plugin-catalog-backend-module-bitbucket': patch
'@backstage/plugin-tech-insights-backend': patch
---

Implemented changes suggested by Deepsource.io including multiple double non-null assertion operators and unexpected awaits for non-promise values.
2 changes: 1 addition & 1 deletion packages/cli/src/commands/plugin/diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default async (cmd: Command) => {
const data = await readPluginData();
const templateFiles = await diffTemplateFiles('default-plugin', data);
await handleAllFiles(fileHandlers, templateFiles, promptFunc);
await finalize();
finalize();
};

// Reads templating data from the existing plugin
Expand Down
2 changes: 1 addition & 1 deletion packages/config-loader/src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export async function loadConfig(
}
}

const envConfigs = await readEnvConfig(process.env);
const envConfigs = readEnvConfig(process.env);

const watchConfigFile = (watchProp: LoadConfigOptionsWatch) => {
let watchedFiles = Array.from(loadedPaths);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ describe('GheAuth AuthSessionStore', () => {

await expect(
withLogCollector(async () => {
await secondStore.setSession('no' as any);
secondStore.setSession('no' as any);
}),
).resolves.toMatchObject({
warn: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('BitbucketRepositoryParser', () => {
presence: 'optional',
}),
];
const actual = await defaultRepositoryParser({
const actual = defaultRepositoryParser({
target: `${browseUrl}${path}`,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion scripts/prepare-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ async function updateBackstageReleaseVersion(repo, type) {
}
} else if (type === 'patch') {
if (preMode) {
throw new Error(`Unexpected pre mode ${preMode} on branch ${branchName}`);
throw new Error(`Unexpected pre mode ${preMode} on current branch`);
}
nextVersion = semver.inc(currentVersion, 'patch');
}
Expand Down