Refactor areAllRunsProducedByCodeQL to use Array.every
This commit is contained in:
parent
f835435c19
commit
016720d81f
3 changed files with 7 additions and 17 deletions
10
lib/upload-lib.js
generated
10
lib/upload-lib.js
generated
|
|
@ -74,14 +74,10 @@ function combineSarifFiles(sarifFiles) {
|
||||||
* @param sarifFiles The list of SARIF files to check.
|
* @param sarifFiles The list of SARIF files to check.
|
||||||
*/
|
*/
|
||||||
function areAllRunsProducedByCodeQL(sarifFiles) {
|
function areAllRunsProducedByCodeQL(sarifFiles) {
|
||||||
for (const sarifFile of sarifFiles) {
|
return sarifFiles.every((sarifFile) => {
|
||||||
const sarifObject = JSON.parse(fs.readFileSync(sarifFile, "utf8"));
|
const sarifObject = JSON.parse(fs.readFileSync(sarifFile, "utf8"));
|
||||||
const allRunsCodeQL = sarifObject.runs?.every((run) => run.tool?.driver?.name === "CodeQL");
|
return sarifObject.runs?.every((run) => run.tool?.driver?.name === "CodeQL");
|
||||||
if (!allRunsCodeQL) {
|
});
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
// Takes a list of paths to sarif files and combines them together using the
|
// Takes a list of paths to sarif files and combines them together using the
|
||||||
// CLI `github merge-results` command when all SARIF files are produced by
|
// CLI `github merge-results` command when all SARIF files are produced by
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -66,21 +66,15 @@ function combineSarifFiles(sarifFiles: string[]): SarifFile {
|
||||||
* @param sarifFiles The list of SARIF files to check.
|
* @param sarifFiles The list of SARIF files to check.
|
||||||
*/
|
*/
|
||||||
function areAllRunsProducedByCodeQL(sarifFiles: string[]): boolean {
|
function areAllRunsProducedByCodeQL(sarifFiles: string[]): boolean {
|
||||||
for (const sarifFile of sarifFiles) {
|
return sarifFiles.every((sarifFile) => {
|
||||||
const sarifObject = JSON.parse(
|
const sarifObject = JSON.parse(
|
||||||
fs.readFileSync(sarifFile, "utf8"),
|
fs.readFileSync(sarifFile, "utf8"),
|
||||||
) as SarifFile;
|
) as SarifFile;
|
||||||
|
|
||||||
const allRunsCodeQL = sarifObject.runs?.every(
|
return sarifObject.runs?.every(
|
||||||
(run) => run.tool?.driver?.name === "CodeQL",
|
(run) => run.tool?.driver?.name === "CodeQL",
|
||||||
);
|
);
|
||||||
|
});
|
||||||
if (!allRunsCodeQL) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Takes a list of paths to sarif files and combines them together using the
|
// Takes a list of paths to sarif files and combines them together using the
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue