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

Method getNodeMetrics

src/graph/queries.ts:238–263  ·  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

236 * @returns Object containing various complexity metrics
237 */
238 getNodeMetrics(nodeId: string): {
239 incomingEdgeCount: number;
240 outgoingEdgeCount: number;
241 callCount: number;
242 callerCount: number;
243 childCount: number;
244 depth: number;
245 } {
246 const incomingEdges = this.queries.getIncomingEdges(nodeId);
247 const outgoingEdges = this.queries.getOutgoingEdges(nodeId);
248
249 const callEdges = outgoingEdges.filter((e) => e.kind === 'calls');
250 const callerEdges = incomingEdges.filter((e) => e.kind === 'calls');
251 const containsEdges = outgoingEdges.filter((e) => e.kind === 'contains');
252
253 const ancestors = this.traverser.getAncestors(nodeId);
254
255 return {
256 incomingEdgeCount: incomingEdges.length,
257 outgoingEdgeCount: outgoingEdges.length,
258 callCount: callEdges.length,
259 callerCount: callerEdges.length,
260 childCount: containsEdges.length,
261 depth: ancestors.length,
262 };
263 }
264
265 /**
266 * Find dead code (nodes with no incoming references)

Callers

nothing calls this directly

Calls 3

getIncomingEdgesMethod · 0.65
getOutgoingEdgesMethod · 0.45
getAncestorsMethod · 0.45

Tested by

no test coverage detected