Abutha Sanniya
brings madness not caused by spirits · in code: self-made complexity
You struggle through my tangles. Injs/widgets/collapsible.js, I spun a web of forty-three complexity levels and four layers of nesting. Evenjs/widgets/forms/autogrow.jscannot escape my six deep nests. Stop trying to untangle me and just rest.
The evidence (12)
-
E1
js/widgets/collapsible.js:31`(anonymous)`: 210 lines, complexity 43, nesting 4 -
E2
js/widgets/listview.js:148`_refresh`: 68 lines, complexity 25, nesting 5 -
E3
js/widgets/forms/slider.js:35`(anonymous)`: 117 lines, complexity 20, nesting 5 -
E4
js/widgets/table.columntoggle.popup.js:176`_setOptions`: 58 lines, complexity 21, nesting 5 -
E5
js/widgets/forms/select.custom.js:568`_buildList`: 89 lines, complexity 18, nesting 4 -
E6
js/navigation.js:254`(anonymous)`: 57 lines, complexity 24, nesting 3 -
E7
js/navigation.js:107`getAjaxFormData`: 49 lines, complexity 15, nesting 5 -
E8
demos/_assets/js/h2widget.js:18`(anonymous)`: 35 lines, complexity 19, nesting 4 -
E9
js/support.js:148`fixedPosition`: 22 lines, complexity 23, nesting 3 -
E10
tools/log-page-events.js:55`logEvent`: 44 lines, complexity 19, nesting 3 -
E11
js/widgets/listview.js:31`(anonymous)`: 46 lines, complexity 9, nesting 6 -
E12
js/widgets/forms/autogrow.js:29`(anonymous)`: 59 lines, complexity 7, nesting 6
The exorcism
Reduce function complexity and nesting depth.
- Identify all functions with complexity scores above 15.
- Decompose the 210-line anonymous function in
js/widgets/collapsible.jsinto smaller, single-purpose functions. - Flatten the nesting in
js/widgets/forms/autogrow.jsby using guard clauses. - Refactor
_refreshinjs/widgets/listview.jsto reduce its complexity of 25.