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

Function readSource

src/graph/test-code.ts:46–56  ·  view source on GitHub ↗
(filePath)

Source from the content-addressed store, hash-verified

44export function testCodeReading(projectRoot: string): (node: Node) => boolean {
45 const sources = new Map<string, string | undefined>();
46 const readSource: SourceReader = (filePath) => {
47 if (!sources.has(filePath)) {
48 let text: string | undefined;
49 try {
50 const abs = validatePathWithinRoot(projectRoot, filePath);
51 text = abs === null ? undefined : readFileSync(abs, 'utf-8');
52 } catch { /* unreadable → not known to be test code */ }
53 sources.set(filePath, text);
54 }
55 return sources.get(filePath);
56 };
57 const verdicts = new Map<string, boolean>();
58 return (node) => {
59 let v = verdicts.get(node.id);

Callers 3

readFunction · 0.85
isTestCodeFunction · 0.85
inCfgTestFileFunction · 0.85

Calls 4

validatePathWithinRootFunction · 0.90
hasMethod · 0.80
getMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected