MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / testFiles

Function testFiles

src/ui-server/api/entrypoints.ts:368–397  ·  view source on GitHub ↗

* The suites that exercise the most of the project, widest first. * * Ranked by reach rather than by size or by module-level calls: a test's * useful property is how much of the codebase runs when it does, and only Go, * Rust and Java put that work inside functions where a "runs something at *

(cg: CodeGraph, limit: number)

Source from the content-addressed store, hash-verified

366 * name.
367 */
368function testFiles(cg: CodeGraph, limit: number): WireList<WireEntryTest> {
369 const candidates = cg
370 .getFiles()
371 .map((file) => toPosixPath(file.path))
372 .filter((path) => isTestPath(path));
373 if (candidates.length === 0) return wireList([], 0);
374
375 const reach = new Map<string, { reaches: number; refs: number }>();
376 for (let i = 0; i < candidates.length; i += TEST_CHUNK) {
377 for (const [path, counts] of cg.getFileReachCounts(candidates.slice(i, i + TEST_CHUNK))) {
378 reach.set(toPosixPath(path), counts);
379 }
380 }
381
382 const ranked = [...reach.entries()]
383 .map(([path, counts]) => ({ path, ...counts }))
384 .sort((a, b) => b.reaches - a.reaches || b.refs - a.refs || a.path.localeCompare(b.path));
385
386 const top = ranked.slice(0, limit);
387 const nodes = new Map(cg.getFileNodes(top.map((row) => row.path)).map((n) => [toPosixPath(n.filePath), n]));
388
389 const items: WireEntryTest[] = [];
390 for (const row of top) {
391 const node = nodes.get(row.path);
392 if (!node) continue;
393 items.push({ ...toNodeRef(node), reaches: row.reaches, refs: row.refs });
394 }
395
396 return wireList(items, Math.max(ranked.length, items.length));
397}
398
399/** The most depended-on symbols, tests, generated files and non-navigable kinds removed. */
400function hubs(cg: CodeGraph, limit: number): WireList<WireEntryHub> {

Callers 1

buildEntryPointsFunction · 0.85

Calls 10

isTestPathFunction · 0.90
wireListFunction · 0.90
toNodeRefFunction · 0.90
mapMethod · 0.80
getFilesMethod · 0.80
pushMethod · 0.80
getMethod · 0.65
getFileReachCountsMethod · 0.45
setMethod · 0.45
getFileNodesMethod · 0.45

Tested by

no test coverage detected