({ score, failedErrors, warningSignals, deductions, checkSummary })
| 225 | } |
| 226 | |
| 227 | function buildRiskReasons({ score, failedErrors, warningSignals, deductions, checkSummary }) { |
| 228 | const reasons = []; |
| 229 | if (failedErrors > 0) { |
| 230 | const examples = deductions |
| 231 | .filter((entry) => entry.status === "fail" && entry.severity === "error") |
| 232 | .slice(0, 3) |
| 233 | .map((entry) => entry.id); |
| 234 | reasons.push( |
| 235 | `Contains ${failedErrors} failing error check${failedErrors === 1 ? "" : "s"}${ |
| 236 | examples.length > 0 ? ` (${examples.join(", ")})` : "" |
| 237 | }.`, |
| 238 | ); |
| 239 | } |
| 240 | if (score < GRADE_THRESHOLDS.C) { |
| 241 | reasons.push(`Overall score is below ${GRADE_THRESHOLDS.C}, which the evaluator treats as high risk.`); |
| 242 | } else if (warningSignals > 0) { |
| 243 | reasons.push( |
| 244 | `Contains ${warningSignals} warning signal${warningSignals === 1 ? "" : "s"} that still need attention.`, |
| 245 | ); |
| 246 | } |
| 247 | if (checkSummary.info > 0 && reasons.length === 0) { |
| 248 | reasons.push("No failing or warning checks were found; remaining items are informational only."); |
| 249 | } |
| 250 | if (reasons.length === 0) { |
| 251 | reasons.push("No failing error checks and no warning signals were found."); |
| 252 | } |
| 253 | return reasons; |
| 254 | } |
| 255 | |
| 256 | export function computeSummary(result) { |
| 257 | const deductions = buildDeductions(result.checks); |
no test coverage detected