* Test-coverage note for a blast-radius entry whose DIRECT callers include no * test file. A helper called only by production code can still be exercised * by tests further up the caller chain (#1475: 40% of directly-unflagged * symbols had a test within 2-3 hops), so walk up to 2 more hops
(cg: CodeGraph, directCallers: Node[], rel: (p: string) => string)
| 3132 | * claiming anything — and even then claim only what was measured. |
| 3133 | */ |
| 3134 | private indirectTestNote(cg: CodeGraph, directCallers: Node[], rel: (p: string) => string): string { |
| 3135 | const MAX_HOPS = 3; // direct callers are hop 1 |
| 3136 | const BUDGET = 64; // getCallers lookups per entry — bounds god-fan-in symbols |
| 3137 | const FILE_CAP = 2; |
| 3138 | let budget = BUDGET; |
| 3139 | const visited = new Set(directCallers.map((n) => n.id)); |
| 3140 | let frontier = directCallers; |
| 3141 | for (let hop = 2; hop <= MAX_HOPS && frontier.length > 0 && budget > 0; hop++) { |
| 3142 | const next: Node[] = []; |
| 3143 | const found = new Set<string>(); |
| 3144 | for (const node of frontier) { |
| 3145 | if (budget-- <= 0) break; |
| 3146 | let callers: Array<{ node: Node }> = []; |
| 3147 | try { callers = cg.getCallers(node.id) as Array<{ node: Node }>; } catch { continue; } |
| 3148 | for (const c of callers) { |
| 3149 | const n = c?.node; |
| 3150 | if (!n || visited.has(n.id)) continue; |
| 3151 | visited.add(n.id); |
| 3152 | const f = rel(n.filePath); |
| 3153 | if (isTestFile(f)) found.add(f); |
| 3154 | else next.push(n); |
| 3155 | } |
| 3156 | } |
| 3157 | if (found.size > 0) { |
| 3158 | const files = [...found]; |
| 3159 | const shown = files.slice(0, FILE_CAP).map((f) => `\`${f}\``).join(', '); |
| 3160 | const more = files.length > FILE_CAP ? ` +${files.length - FILE_CAP}` : ''; |
| 3161 | return `; tested via callers: ${shown}${more}`; |
| 3162 | } |
| 3163 | frontier = next; |
| 3164 | } |
| 3165 | // Budget exhaustion means hops 2-3 weren't fully searched — fall back to |
| 3166 | // the weaker claim that IS established by the direct-caller check. |
| 3167 | return budget > 0 |
| 3168 | ? `; no tests found within ${MAX_HOPS} caller hops` |
| 3169 | : '; no test calls this directly'; |
| 3170 | } |
| 3171 | |
| 3172 | /** |
| 3173 | * Graph-connectivity relevance via Random-Walk-with-Restart (personalized |
no test coverage detected