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

Function tallyModules

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

The non-test modules a given depth would draw, and how concentrated they are.

(
  files: ReadonlyArray<{ path: string; symbols: number; test: boolean }>,
  root: string,
  depth: number,
  passThrough?: ReadonlySet<string>
)

Source from the content-addressed store, hash-verified

395
396/** The non-test modules a given depth would draw, and how concentrated they are. */
397function tallyModules(
398 files: ReadonlyArray<{ path: string; symbols: number; test: boolean }>,
399 root: string,
400 depth: number,
401 passThrough?: ReadonlySet<string>
402): { count: number; share: number; largestFiles: number } {
403 const byModule = new Map<string, { symbols: number; files: number }>();
404 let total = 0;
405 for (const file of files) {
406 if (file.test) continue;
407 const assigned = moduleIdFor(file.path, root, depth, passThrough);
408 if (assigned === null) continue;
409 let entry = byModule.get(assigned.id);
410 if (!entry) byModule.set(assigned.id, (entry = { symbols: 0, files: 0 }));
411 entry.symbols += file.symbols;
412 entry.files += 1;
413 total += file.symbols;
414 }
415 let largest = { symbols: 0, files: 0 };
416 for (const entry of byModule.values()) {
417 if (entry.symbols > largest.symbols) largest = entry;
418 }
419 return {
420 count: byModule.size,
421 share: total === 0 ? 0 : largest.symbols / total,
422 largestFiles: largest.files,
423 };
424}
425
426/**
427 * How many segments name a module, when the reader has not said.

Callers 2

pickDefaultDepthFunction · 0.85
pickDefaultViewFunction · 0.85

Calls 3

moduleIdForFunction · 0.85
getMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected