Delete unused fixInvalidNotifications function

This commit is contained in:
Michael B. Gale
2026-03-01 14:26:41 +00:00
parent 40aec383a1
commit 3b16d31abc
2 changed files with 2 additions and 148 deletions

View File

@@ -2,18 +2,9 @@ import * as fs from "fs";
import test from "ava";
import {
getRecordingLogger,
LoggedMessage,
setupTests,
} from "../testing-utils";
import { setupTests } from "../testing-utils";
import {
fixInvalidNotifications,
getToolNames,
SarifLocation,
type SarifFile,
} from ".";
import { getToolNames, type SarifFile } from ".";
setupTests(test);
@@ -25,64 +16,3 @@ test("getToolNames", (t) => {
const toolNames = getToolNames(JSON.parse(input) as SarifFile);
t.deepEqual(toolNames, ["CodeQL command-line toolchain", "ESLint"]);
});
function createMockSarifWithNotification(
locations: SarifLocation[],
): SarifFile {
return {
runs: [
{
tool: {
driver: {
name: "CodeQL",
},
},
invocations: [
{
toolExecutionNotifications: [
{
locations,
},
],
},
],
},
],
};
}
const stubLocation: SarifLocation = {
physicalLocation: {
artifactLocation: {
uri: "file1",
},
},
};
test("fixInvalidNotifications leaves notifications with unique locations alone", (t) => {
const messages: LoggedMessage[] = [];
const result = fixInvalidNotifications(
createMockSarifWithNotification([stubLocation]),
getRecordingLogger(messages),
);
t.deepEqual(result, createMockSarifWithNotification([stubLocation]));
t.is(messages.length, 1);
t.deepEqual(messages[0], {
type: "debug",
message: "No duplicate locations found in SARIF notification objects.",
});
});
test("fixInvalidNotifications removes duplicate locations", (t) => {
const messages: LoggedMessage[] = [];
const result = fixInvalidNotifications(
createMockSarifWithNotification([stubLocation, stubLocation]),
getRecordingLogger(messages),
);
t.deepEqual(result, createMockSarifWithNotification([stubLocation]));
t.is(messages.length, 1);
t.deepEqual(messages[0], {
type: "info",
message: "Removed 1 duplicate locations from SARIF notification objects.",
});
});