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