Use Array.isArray

This commit is contained in:
Henry Mercer 2023-03-27 15:59:29 +01:00
parent 1e7a38893c
commit 57eca7cbb2
3 changed files with 9 additions and 9 deletions

8
lib/util.js generated
View file

@ -676,7 +676,7 @@ function fixInvalidNotifications(sarif, logger) {
`${shared_environment_1.CODEQL_ACTION_DISABLE_DUPLICATE_LOCATION_FIX} environment variable.`);
return sarif;
}
if (!(sarif.runs instanceof Array)) {
if (!Array.isArray(sarif.runs)) {
return sarif;
}
// Ensure that the array of locations for each SARIF notification contains unique locations.
@ -687,19 +687,19 @@ function fixInvalidNotifications(sarif, logger) {
...sarif,
runs: sarif.runs.map((run) => {
if (run.tool?.driver?.name !== "CodeQL" ||
!(run.invocations instanceof Array)) {
!Array.isArray(run.invocations)) {
return run;
}
return {
...run,
invocations: run.invocations.map((invocation) => {
if (!(invocation.toolExecutionNotifications instanceof Array)) {
if (!Array.isArray(invocation.toolExecutionNotifications)) {
return invocation;
}
return {
...invocation,
toolExecutionNotifications: invocation.toolExecutionNotifications.map((notification) => {
if (!(notification.locations instanceof Array)) {
if (!Array.isArray(notification.locations)) {
return notification;
}
const newLocations = removeDuplicateLocations(notification.locations);

File diff suppressed because one or more lines are too long

View file

@ -823,7 +823,7 @@ export function fixInvalidNotifications(
);
return sarif;
}
if (!(sarif.runs instanceof Array)) {
if (!Array.isArray(sarif.runs)) {
return sarif;
}
@ -837,21 +837,21 @@ export function fixInvalidNotifications(
runs: sarif.runs.map((run) => {
if (
run.tool?.driver?.name !== "CodeQL" ||
!(run.invocations instanceof Array)
!Array.isArray(run.invocations)
) {
return run;
}
return {
...run,
invocations: run.invocations.map((invocation) => {
if (!(invocation.toolExecutionNotifications instanceof Array)) {
if (!Array.isArray(invocation.toolExecutionNotifications)) {
return invocation;
}
return {
...invocation,
toolExecutionNotifications:
invocation.toolExecutionNotifications.map((notification) => {
if (!(notification.locations instanceof Array)) {
if (!Array.isArray(notification.locations)) {
return notification;
}
const newLocations = removeDuplicateLocations(