* Get complexity metrics for a node * * @param nodeId - ID of the node * @returns Object containing various complexity metrics
(nodeId: string)
| 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) |
nothing calls this directly
no test coverage detected