Section 6.4Source:
server/src/analytics/health/fan-out/calculateFanOutHealth.tsFan-Out Health & RMS (18%)
Measuring outgoing relationship concentration using Root Mean Square (RMS) to penalize outlier hotspot files and functions.
Source:
server/src/analytics/health/fan-out/calculateFanOutHealth.tsWhy Simple Average is Insufficient
In a repository with 100 files, if 99 files have a fan-out of 1 and 1 file has an extreme fan-out of 100 (a God object), the arithmetic mean is only ≈ 2.0, concealing the architectural risk.
CodeGraph uses Root Mean Square (RMS):
RMS = √( (∑ x²) / N )
Squaring each term before averaging makes large outlier hotspots distinctly visible:
server/src/analytics/health/fan-out/calculateFanOutHealth.ts
12345678910111213141516let totalFanOut = 0; let squaredFanOut = 0; let maximumFanOut = 0; for (const nodeId of nodeIds) { const fanOut = graph.outgoingEdges.get(nodeId)?.size ?? 0; totalFanOut += fanOut; squaredFanOut += fanOut * fanOut; // Squaring amplifies outliers maximumFanOut = Math.max(maximumFanOut, fanOut); } const averageFanOut = totalFanOut / nodeIds.length; const rootMeanSquareFanOut = Math.sqrt(squaredFanOut / nodeIds.length); const normalizedRisk = 0.5 * rootMeanSquareFanOut; const score = 100 / (1 + normalizedRisk);