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

Method getNodeMetrics

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

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