Skip to content

Commit 1721ce7

Browse files
committed
Address minor review comments
1 parent b43d146 commit 1721ce7

File tree

9 files changed

+461
-475
lines changed

9 files changed

+461
-475
lines changed

lib/analyze-action.js

Lines changed: 127 additions & 131 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/init-action-post.js

Lines changed: 130 additions & 132 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/upload-lib.js

Lines changed: 100 additions & 104 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/upload-sarif-action.js

Lines changed: 82 additions & 86 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/sarif/index.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,11 @@ export function combineSarifFiles(
7171

7272
/**
7373
* Checks whether all the runs in the given SARIF files were produced by CodeQL.
74-
* @param sarifObjects The list of SARIF objects to check.
74+
* @param sarifLogs The list of SARIF objects to check.
7575
*/
76-
export function areAllRunsProducedByCodeQL(sarifObjects: sarif.Log[]): boolean {
77-
return sarifObjects.every((sarifObject) => {
78-
return sarifObject.runs?.every(
79-
(run) => run.tool?.driver?.name === "CodeQL",
80-
);
76+
export function areAllRunsProducedByCodeQL(sarifLogs: sarif.Log[]): boolean {
77+
return sarifLogs.every((sarifLog: sarif.Log) => {
78+
return sarifLog.runs?.every((run) => run.tool?.driver?.name === "CodeQL");
8179
});
8280
}
8381

@@ -95,13 +93,13 @@ function createRunKey(run: sarif.Run): RunKey {
9593
/**
9694
* Checks whether all runs in the given SARIF files are unique (based on the
9795
* criteria used by Code Scanning to determine analysis categories).
98-
* @param sarifObjects The list of SARIF objects to check.
96+
* @param sarifLogs The list of SARIF objects to check.
9997
*/
100-
export function areAllRunsUnique(sarifObjects: sarif.Log[]): boolean {
98+
export function areAllRunsUnique(sarifLogs: sarif.Log[]): boolean {
10199
const keys = new Set<string>();
102100

103-
for (const sarifObject of sarifObjects) {
104-
for (const run of sarifObject.runs) {
101+
for (const sarifLog of sarifLogs) {
102+
for (const run of sarifLog.runs) {
105103
const key = JSON.stringify(createRunKey(run));
106104

107105
// If the key already exists, the runs are not unique.

src/upload-lib.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ test("validateSarifFileSchema - valid", (t) => {
2626
const inputFile = `${__dirname}/../src/testdata/valid-sarif.sarif`;
2727
t.notThrows(() =>
2828
uploadLib.validateSarifFileSchema(
29-
uploadLib.readSarifFile(inputFile),
29+
uploadLib.readSarifFileOrThrow(inputFile),
3030
inputFile,
3131
getRunnerLogger(true),
3232
),
@@ -37,7 +37,7 @@ test("validateSarifFileSchema - invalid", (t) => {
3737
const inputFile = `${__dirname}/../src/testdata/invalid-sarif.sarif`;
3838
t.throws(() =>
3939
uploadLib.validateSarifFileSchema(
40-
uploadLib.readSarifFile(inputFile),
40+
uploadLib.readSarifFileOrThrow(inputFile),
4141
inputFile,
4242
getRunnerLogger(true),
4343
),
@@ -608,7 +608,7 @@ test("accept results with invalid artifactLocation.uri value", (t) => {
608608

609609
const sarifFile = `${__dirname}/../src/testdata/with-invalid-uri.sarif`;
610610
uploadLib.validateSarifFileSchema(
611-
uploadLib.readSarifFile(sarifFile),
611+
uploadLib.readSarifFileOrThrow(sarifFile),
612612
sarifFile,
613613
mockLogger,
614614
);

0 commit comments

Comments
 (0)