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

Method getNodeMetrics

src/graph/queries.ts:271–296  ·  view source on GitHub ↗

* Get complexity metrics for a node * * @param nodeId - ID of the node * @returns Object containing various complexity metrics

(nodeId: string)

Source from the content-addressed store, hash-verified

269 * @returns Object containing various complexity metrics
270 */
271 getNodeMetrics(nodeId: string): {
272 incomingEdgeCount: number;
273 outgoingEdgeCount: number;
274 callCount: number;
275 callerCount: number;
276 childCount: number;
277 depth: number;
278 } {
279 const incomingEdges = this.queries.getIncomingEdges(nodeId);
280 const outgoingEdges = this.queries.getOutgoingEdges(nodeId);
281
282 const callEdges = outgoingEdges.filter((e) => e.kind === 'calls');
283 const callerEdges = incomingEdges.filter((e) => e.kind === 'calls');
284 const containsEdges = outgoingEdges.filter((e) => e.kind === 'contains');
285
286 const ancestors = this.traverser.getAncestors(nodeId);
287
288 return {
289 incomingEdgeCount: incomingEdges.length,
290 outgoingEdgeCount: outgoingEdges.length,
291 callCount: callEdges.length,
292 callerCount: callerEdges.length,
293 childCount: containsEdges.length,
294 depth: ancestors.length,
295 };
296 }
297
298 /**
299 * Find dead code (nodes with no incoming references)

Callers

nothing calls this directly

Calls 3

getIncomingEdgesMethod · 0.45
getOutgoingEdgesMethod · 0.45
getAncestorsMethod · 0.45

Tested by

no test coverage detected