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

Method testCodeReading

src/mcp/tools.ts:4186–4206  ·  view source on GitHub ↗

* Whether a caller is test code, for one blast-radius section. A Rust unit * test is told by its file's source (an inline `#[cfg(test)]` module, or the * parent's `#[cfg(test)] mod tests;`), so each file is read once.

(cg: CodeGraph)

Source from the content-addressed store, hash-verified

4184 * parent's `#[cfg(test)] mod tests;`), so each file is read once.
4185 */
4186 private testCodeReading(cg: CodeGraph): (node: Node) => boolean {
4187 const root = cg.getProjectRoot();
4188 const sources = new Map<string, string | undefined>();
4189 const readSource: SourceReader = (filePath) => {
4190 if (!sources.has(filePath)) {
4191 let text: string | undefined;
4192 try {
4193 const abs = validatePathWithinRoot(root, filePath);
4194 text = abs === null ? undefined : readFileSync(abs, 'utf-8');
4195 } catch { /* unreadable → not known to be test code */ }
4196 sources.set(filePath, text);
4197 }
4198 return sources.get(filePath);
4199 };
4200 const verdicts = new Map<string, boolean>();
4201 return (node) => {
4202 let v = verdicts.get(node.id);
4203 if (v === undefined) verdicts.set(node.id, (v = isTestCode(node, readSource)));
4204 return v;
4205 };
4206 }
4207
4208 /**
4209 * Compact "blast radius" for the entry symbols of an explore result: who

Callers 2

exploreOneSymbolMethod · 0.95

Calls 4

isTestCodeFunction · 0.90
getProjectRootMethod · 0.65
getMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected