( comments: JsonValue[], total: number, limit: number, )
| 1314 | } |
| 1315 | |
| 1316 | function compactPrCloseCoverageProofCommentWindow( |
| 1317 | comments: JsonValue[], |
| 1318 | total: number, |
| 1319 | limit: number, |
| 1320 | ): unknown[] { |
| 1321 | const boundedLimit = Math.max(0, Math.floor(limit)); |
| 1322 | const boundedTotal = Math.max(0, Math.floor(total)); |
| 1323 | if (boundedTotal <= boundedLimit && comments.length <= boundedLimit) { |
| 1324 | return comments.map(compactPrCloseCoverageProofComment); |
| 1325 | } |
| 1326 | if (boundedLimit === 0) { |
| 1327 | return [{ omitted: boundedTotal, note: "comments omitted from proof context" }]; |
| 1328 | } |
| 1329 | const keepStart = Math.floor(boundedLimit / 2); |
| 1330 | const keepEnd = Math.max(0, boundedLimit - keepStart); |
| 1331 | const omitted = Math.max(0, boundedTotal - keepStart - keepEnd); |
| 1332 | return [ |
| 1333 | ...comments.slice(0, keepStart).map(compactPrCloseCoverageProofComment), |
| 1334 | ...(omitted > 0 ? [{ omitted, note: "middle comments omitted from proof context" }] : []), |
| 1335 | ...comments.slice(comments.length - keepEnd).map(compactPrCloseCoverageProofComment), |
| 1336 | ]; |
| 1337 | } |
| 1338 | |
| 1339 | function prCloseCoverageProofRelationshipSignals({ action, actionName, coveringRef }: LooseRecord) { |
| 1340 | const signals = [ |
no outgoing calls
no test coverage detected