From d0f122ad8758b1b2fe6ab34eb720aa76a5c4b679 Mon Sep 17 00:00:00 2001 From: Koen Vlaswinkel Date: Thu, 21 Dec 2023 16:11:47 +0100 Subject: [PATCH] Remove formatLegacyMessage --- .../src/query-server/format-legacy-message.ts | 23 ------------- .../no-workspace/query-results.test.ts | 32 ------------------- 2 files changed, 55 deletions(-) delete mode 100644 extensions/ql-vscode/src/query-server/format-legacy-message.ts diff --git a/extensions/ql-vscode/src/query-server/format-legacy-message.ts b/extensions/ql-vscode/src/query-server/format-legacy-message.ts deleted file mode 100644 index a7c365ad5..000000000 --- a/extensions/ql-vscode/src/query-server/format-legacy-message.ts +++ /dev/null @@ -1,23 +0,0 @@ -import * as legacyMessages from "./legacy-messages"; - -// Used for formatting the result of a legacy query which might still be in the -// user's query history. -export function formatLegacyMessage(result: legacyMessages.EvaluationResult) { - switch (result.resultType) { - case legacyMessages.QueryResultType.CANCELLATION: - return `cancelled after ${Math.round( - result.evaluationTime / 1000, - )} seconds`; - case legacyMessages.QueryResultType.OOM: - return "out of memory"; - case legacyMessages.QueryResultType.SUCCESS: - return `finished in ${Math.round(result.evaluationTime / 1000)} seconds`; - case legacyMessages.QueryResultType.TIMEOUT: - return `timed out after ${Math.round( - result.evaluationTime / 1000, - )} seconds`; - case legacyMessages.QueryResultType.OTHER_ERROR: - default: - return result.message ? `failed: ${result.message}` : "failed"; - } -} diff --git a/extensions/ql-vscode/test/vscode-tests/no-workspace/query-results.test.ts b/extensions/ql-vscode/test/vscode-tests/no-workspace/query-results.test.ts index 3b116062e..fa921459f 100644 --- a/extensions/ql-vscode/test/vscode-tests/no-workspace/query-results.test.ts +++ b/extensions/ql-vscode/test/vscode-tests/no-workspace/query-results.test.ts @@ -25,13 +25,8 @@ import { import { CodeQLCliServer, SourceInfo } from "../../../src/codeql-cli/cli"; import { CancellationTokenSource, Uri } from "vscode"; import { tmpDir } from "../../../src/tmp-dir"; -import { - EvaluationResult, - QueryResultType, -} from "../../../src/query-server/legacy-messages"; import { sleep } from "../../../src/common/time"; import { mockedObject } from "../utils/mocking.helpers"; -import { formatLegacyMessage } from "../../../src/query-server/format-legacy-message"; describe("query-results", () => { let queryPath: string; @@ -106,33 +101,6 @@ describe("query-results", () => { expect(completedQuery.getResultsPath("zxa")).toBe("bxa"); }); - it("should format the statusString", () => { - const evalResult: EvaluationResult = { - resultType: QueryResultType.OTHER_ERROR, - evaluationTime: 12340, - queryId: 3, - runId: 1, - }; - - evalResult.message = "Tremendously"; - expect(formatLegacyMessage(evalResult)).toBe("failed: Tremendously"); - - evalResult.resultType = QueryResultType.OTHER_ERROR; - expect(formatLegacyMessage(evalResult)).toBe("failed: Tremendously"); - - evalResult.resultType = QueryResultType.CANCELLATION; - evalResult.evaluationTime = 2345; - expect(formatLegacyMessage(evalResult)).toBe("cancelled after 2 seconds"); - - evalResult.resultType = QueryResultType.OOM; - expect(formatLegacyMessage(evalResult)).toBe("out of memory"); - - evalResult.resultType = QueryResultType.SUCCESS; - expect(formatLegacyMessage(evalResult)).toBe("finished in 2 seconds"); - - evalResult.resultType = QueryResultType.TIMEOUT; - expect(formatLegacyMessage(evalResult)).toBe("timed out after 2 seconds"); - }); it("should updateSortState", async () => { // setup const fqi = createMockFullQueryInfo(