(result, summary)
| 309 | } |
| 310 | |
| 311 | export function enrichSummary(result, summary) { |
| 312 | const deductions = Array.isArray(summary?.deductions) ? summary.deductions : buildDeductions(result.checks); |
| 313 | const categoryDeductions = Array.isArray(summary?.categoryDeductions) |
| 314 | ? summary.categoryDeductions |
| 315 | : buildCategoryDeductions(deductions); |
| 316 | const failedErrors = result.checks.filter( |
| 317 | (check) => check.status === "fail" && check.severity === "error", |
| 318 | ).length; |
| 319 | const warningSignals = result.checks.filter((check) => check.status === "warn").length; |
| 320 | const actionableChecks = rankActionableChecks(result.checks).map(summarizeFinding); |
| 321 | const nextSummary = { |
| 322 | ...summary, |
| 323 | deductions, |
| 324 | categoryDeductions, |
| 325 | }; |
| 326 | |
| 327 | return { |
| 328 | ...nextSummary, |
| 329 | whyBullets: |
| 330 | Array.isArray(nextSummary.whyBullets) && nextSummary.whyBullets.length > 0 |
| 331 | ? nextSummary.whyBullets |
| 332 | : buildWhyBullets(result, { ...nextSummary, categoryDeductions }, failedErrors, warningSignals), |
| 333 | fixFirst: |
| 334 | Array.isArray(nextSummary.fixFirst) && nextSummary.fixFirst.length > 0 |
| 335 | ? nextSummary.fixFirst |
| 336 | : actionableChecks.slice(0, 3), |
| 337 | watchNext: |
| 338 | Array.isArray(nextSummary.watchNext) && nextSummary.watchNext.length > 0 |
| 339 | ? nextSummary.watchNext |
| 340 | : actionableChecks.slice(3, 6), |
| 341 | }; |
| 342 | } |
no test coverage detected