Abutha Sanniya
brings madness not caused by spirits · in code: self-made complexity
A web of lines I wove in request.js, where init stretches to 137 lines of pure chaos. I watched the developers drown in 58 paths of complexity while getNewAgent added another 99 lines of confusion. You think a few refactors can untangle my knot. Very well, I shall vanish.
The evidence (2)
-
E1
request.js:141`Request.prototype.init`: 137 lines, complexity 58, nesting 5 -
E2
request.js:585`Request.prototype.getNewAgent`: 99 lines, complexity 35, nesting 3
The exorcism
Decompose the monolithic Request.prototype.init function to reduce cyclomatic complexity.
- Extract the option-parsing logic from request.js line 141 into a new Request.prototype.setDefaults method
- Move the agent configuration logic to a dedicated helper function
- Delegate redirect-specific setup to a separate method to reduce nesting