Across 162 functions in ant-design/ant-design-pro, 4 have reached critical band status — and the risk is concentrated in two layers: HTTP error handling and mock data endpoints. The anonymous function in src/requestErrorConfig.ts leads with a risk score of 12.12 driven by CC 19 — but it hasn’t been touched in 60 days, placing it in the debt quadrant. The same is true of the top mock functions in listTableList.ts (161 days untouched). These are structural debt concerns: not active regression risks today, but high blast-radius problems when development next reaches these files. The exception is the table-list page component, which is in the fire quadrant with active recent changes. ant-design-pro is Ant Design’s enterprise-grade React scaffolding template, and at this commit (607e63f), its critical hotspots cluster around request lifecycle management and mock API simulation — the seams most likely to surface accumulated debt under future feature development.
The table below ranks functions by activity-weighted risk — a score that multiplies structural complexity by recent commit frequency. A function that is both hard to understand (high cyclomatic complexity) and actively changing is a higher priority than one that is complex but untouched. CC = cyclomatic complexity (independent execution paths); ND = max nesting depth; FO = fan-out (distinct callees).
Top 5 Hotspots
| Function | File | Risk | CC | ND | FO |
|---|---|---|---|---|---|
<anonymous> | src/requestErrorConfig.ts | 12.1 | 19 | 3 | 3 |
postRule | mock/listTableList.ts | 11.8 | 13 | 2 | 11 |
<anonymous> | src/pages/table-list/index.tsx | 10.7 | 6 | 1 | 19 |
getRule | mock/listTableList.ts | 10.1 | 11 | 3 | 9 |
<anonymous> | src/pages/user/login/index.tsx | 8.5 | 12 | 2 | 17 |
Hotspot Analysis
<anonymous> — src/requestErrorConfig.ts
Based on its file path, this anonymous function almost certainly defines the central HTTP error-handling configuration — intercepting responses, classifying error codes, and dispatching user-facing messages. A cyclomatic complexity of 19 means there are at least 19 independent execution paths through this logic, each a distinct error scenario that requires its own test case. The exit_heavy pattern compounds this: multiple return paths make it difficult to reason about which branch executes under which condition. This function hasn’t been touched in 60 days — it sits in the debt quadrant, carrying structural complexity that represents a high blast-radius risk when this file is next changed.
Recommendation: Before any further changes, add characterization tests that cover each of the 19 logical branches, then extract distinct error-classification cases (e.g. network errors, auth failures, server errors) into named handler functions to bring CC below 10.
postRule — mock/listTableList.ts
The name and file path indicate this function handles POST requests in the mock table-list API — likely validating input, mutating mock state, and returning a shaped response. Its fan-out of 11 is the telling metric: calling 11 distinct functions from a single mock handler means it is acting as a coordination hub, and the god_function pattern confirms this — changes here can ripple across a wide surface of mock utilities and shared state. CC 13 with an exit_heavy pattern means there are multiple conditional return paths through that coordination logic. This function hasn’t been touched in 161 days — it’s in the debt quadrant, and its structural complexity warrants refactoring before the mock layer is next developed.
Recommendation: Decompose postRule by extracting validation, state mutation, and response-shaping into separate, independently testable functions; this will reduce both CC and fan-out and shrink the blast radius of future changes.
<anonymous> — src/pages/table-list/index.tsx
This anonymous function lives in the table-list page component and, given the long_function and god_function patterns, likely handles the full lifecycle of the table view — data fetching, column configuration, action callbacks, and render logic — all in one place. Its fan-out of 19 is the highest in the critical band and is the dominant structural risk: with 19 distinct callees, a change to any one of those dependencies could require a corresponding update here, making this function a shotgun target. The quadrant classification of ‘fire’ — meaning both complex and actively changing — is reinforced by an activity risk of 10.73 against a recent commit activity of 9.7.
Recommendation: Apply extract-method refactoring to separate data-fetching logic, column definitions, and action handlers into dedicated hooks or sub-components; auditing all 19 fan-out targets first will clarify which extractions deliver the most coupling reduction.
Patterns Found
Antipatterns detected across the top functions in this snapshot:
| Pattern | Occurrences |
|---|---|
exit_heavy | 3 |
god_function | 3 |
long_function | 2 |
These labels belong to two tiers — Tier 1 (structural): complex_branching, deeply_nested, exit_heavy, long_function, god_function. Tier 2 (relational/temporal): hub_function, cyclic_hub, middle_man, neighbor_risk, stale_complex, churn_magnet, shotgun_target, volatile_god.
Key Takeaways
- The anonymous function in src/requestErrorConfig.ts has CC 19 and hasn’t been touched in 60 days — refactor it before the next change lands on this file; its 19 paths require at least 19 test cases and characterization tests should be written first.
- postRule in mock/listTableList.ts has a fan-out of 11, is tagged as a god_function, and is 161 days untouched — structural debt that warrants refactoring before the mock layer is next developed; any change here risks rippling across 11 downstream dependencies.
- The table-list page component’s anonymous function reaches a fan-out of 19 and sits in the ‘fire’ quadrant — both complex and actively changing — making it the most immediate refactoring priority to isolate data-fetching, column configuration, and action handling into separate units.
Reproduce This Analysis
git clone https://github.com/ant-design/ant-design-pro
cd ant-design-pro
git checkout 607e63f4fdb49d78306a618f2b2c29291ce85500
hotspots analyze . --mode snapshot --explain-patterns --force
To run the same analysis on your own codebase, run hotspots analyze . --mode snapshot in any local git repo — no configuration required.
Hotspots highlights structural and activity risk — not “bad code.” Findings are a prioritization aid, not a bug predictor. Editorial policy →