mirror of
https://github.com/openclaw/openclaw.git
synced 2026-10-04 02:00:10 +00:00
Reuse the existing scripts groupBy owner in the shared test-report renderer. Preserve first-seen order, finding order, complete counts, output caps and all CLI/guard contracts. Remove six production lines without changing tests or dependencies. Validation: 19 existing focused cases, scoped lint, both zero-cycle checks and independent review. Release notes: internal tooling cleanup only.
32 lines
884 B
TypeScript
32 lines
884 B
TypeScript
import { groupBy } from "./group-by.mts";
|
|
|
|
export function renderFindingGroups<T extends { file: string }>(
|
|
findings: T[],
|
|
limit: number,
|
|
renderFinding: (finding: T) => string,
|
|
): string[] {
|
|
// Group before applying the cap so counts stay complete and files keep first-seen order.
|
|
const grouped = groupBy(findings, (finding) => finding.file);
|
|
|
|
const lines: string[] = [];
|
|
let shown = 0;
|
|
for (const [file, fileFindings] of grouped) {
|
|
if (shown >= limit) {
|
|
break;
|
|
}
|
|
lines.push(`- ${file} (${fileFindings.length})`);
|
|
for (const finding of fileFindings) {
|
|
if (shown >= limit) {
|
|
break;
|
|
}
|
|
lines.push(renderFinding(finding));
|
|
shown += 1;
|
|
}
|
|
}
|
|
if (findings.length > shown) {
|
|
lines.push(
|
|
`... ${findings.length - shown} more finding(s) not shown; pass --limit 0 to show all.`,
|
|
);
|
|
}
|
|
return lines;
|
|
}
|