Skip to content

Commit

Permalink
Use for-of
Browse files Browse the repository at this point in the history
  • Loading branch information
carmocca committed Nov 22, 2022
1 parent 5acf410 commit cf6fc27
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
21 changes: 13 additions & 8 deletions dist/check-group/core/satisfy_expected_checks.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.getSubProjResult = exports.getChecksResult = void 0;
var getChecksResult = function (checks, postedChecks) {
var result = "all_passing";
checks.forEach(function (check) {
for (var _i = 0, checks_1 = checks; _i < checks_1.length; _i++) {
var check = checks_1[_i];
var relevant = check in postedChecks;
if (relevant && postedChecks[check].conclusion !== "success") {
// at least one check failed
Expand All @@ -13,26 +14,30 @@ var getChecksResult = function (checks, postedChecks) {
// some checks are pending or missing
result = "pending";
}
});
}
;
return result;
};
exports.getChecksResult = getChecksResult;
var getSubProjResult = function (subProjs, postedChecks) {
var result = "all_passing";
subProjs.forEach(function (subProj) {
subProj.checks.forEach(function (check) {
for (var _i = 0, subProjs_1 = subProjs; _i < subProjs_1.length; _i++) {
var subProj = subProjs_1[_i];
for (var _a = 0, _b = subProj.checks; _a < _b.length; _a++) {
var check = _b[_a];
var relevant = check in postedChecks;
if (relevant && postedChecks[check].conclusion !== "success") {
// at least one check failed
result = "has_failure";
return; // continue
return "has_failure";
}
if (!relevant || postedChecks[check].conclusion === null) {
// some checks are pending or missing
result = "pending";
}
});
});
}
;
}
;
return result;
};
exports.getSubProjResult = getSubProjResult;
15 changes: 7 additions & 8 deletions src/check-group/core/satisfy_expected_checks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const getChecksResult = (
postedChecks: Record<string, CheckRunData>,
): CheckResult => {
let result: CheckResult = "all_passing";
checks.forEach((check) => {
for (const check of checks) {
const relevant = check in postedChecks
if (relevant && postedChecks[check].conclusion !== "success") {
// at least one check failed
Expand All @@ -15,7 +15,7 @@ export const getChecksResult = (
// some checks are pending or missing
result = "pending";
}
});
};
return result;
}

Expand All @@ -24,19 +24,18 @@ export const getSubProjResult = (
postedChecks: Record<string, CheckRunData>,
): CheckResult => {
let result: CheckResult = "all_passing";
subProjs.forEach((subProj) => {
subProj.checks.forEach((check) => {
for (const subProj of subProjs) {
for (const check of subProj.checks) {
const relevant = check in postedChecks
if (relevant && postedChecks[check].conclusion !== "success") {
// at least one check failed
result = "has_failure";
return // continue
return "has_failure";
}
if (!relevant || postedChecks[check].conclusion === null) {
// some checks are pending or missing
result = "pending";
}
});
});
};
};
return result;
};

0 comments on commit cf6fc27

Please sign in to comment.