Use a regular const instead of storing this on the class

This commit is contained in:
Elena Tanasoiu
2023-04-11 09:50:48 +00:00
parent f949eda5ff
commit 911c3af225
2 changed files with 18 additions and 15 deletions

View File

@@ -15,23 +15,23 @@ type QueryLanguagesToDatabaseMap = {
[id: string]: string;
};
export const QUERY_LANGUAGE_TO_DATABASE_REPO: QueryLanguagesToDatabaseMap = {
cpp: "protocolbuffers/protobuf",
csharp: "dotnet/efcore",
go: "evanw/esbuild",
java: "google/guava",
javascript: "facebook/react",
python: "pallets/flask",
ruby: "rails/rails",
swift: "Alamofire/Alamofire",
};
export class SkeletonQueryWizard {
private language: string | undefined;
private folderName: string | undefined;
private fileName = "example.ql";
private storagePath: string | undefined;
QUERY_LANGUAGE_TO_DATABASE_REPO: QueryLanguagesToDatabaseMap = {
cpp: "protocolbuffers/protobuf",
csharp: "dotnet/efcore",
go: "evanw/esbuild",
java: "google/guava",
javascript: "facebook/react",
python: "pallets/flask",
ruby: "rails/rails",
swift: "Alamofire/Alamofire",
};
constructor(
private readonly cliServer: CodeQLCliServer,
private readonly progress: ProgressCallback,
@@ -206,7 +206,7 @@ export class SkeletonQueryWizard {
maxStep: 3,
});
const githubRepoNwo = this.QUERY_LANGUAGE_TO_DATABASE_REPO[this.language];
const githubRepoNwo = QUERY_LANGUAGE_TO_DATABASE_REPO[this.language];
await databaseFetcher.downloadGitHubDatabase(
githubRepoNwo,
@@ -229,7 +229,7 @@ export class SkeletonQueryWizard {
throw new Error("Workspace storage path is undefined");
}
const databaseNwo = this.QUERY_LANGUAGE_TO_DATABASE_REPO[this.language];
const databaseNwo = QUERY_LANGUAGE_TO_DATABASE_REPO[this.language];
const databaseItem = await this.databaseManager.digForDatabaseItem(
this.language,

View File

@@ -1,5 +1,8 @@
import { CodeQLCliServer } from "../../../src/cli";
import { SkeletonQueryWizard } from "../../../src/skeleton-query-wizard";
import {
QUERY_LANGUAGE_TO_DATABASE_REPO,
SkeletonQueryWizard,
} from "../../../src/skeleton-query-wizard";
import { mockedObject, mockedQuickPickItem } from "../utils/mocking.helpers";
import * as tmp from "tmp";
import { TextDocument, window, workspace, WorkspaceFolder } from "vscode";
@@ -191,7 +194,7 @@ describe("SkeletonQueryWizard", () => {
let databaseItem: DatabaseItem;
beforeEach(async () => {
databaseNwo = wizard.QUERY_LANGUAGE_TO_DATABASE_REPO[chosenLanguage];
databaseNwo = QUERY_LANGUAGE_TO_DATABASE_REPO[chosenLanguage];
databaseItem = {
name: databaseNwo,