Skip to content

refactor: burn down complexity hotspots across model, view, controller, events, global, seed - #3435

Merged
bpamiri merged 7 commits into
developfrom
peter/complexity-burn-down-1
Aug 28, 2026
Merged

refactor: burn down complexity hotspots across model, view, controller, events, global, seed#3435
bpamiri merged 7 commits into
developfrom
peter/complexity-burn-down-1

Conversation

@bpamiri

@bpamiri bpamiri commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

First burn-down wave on the framework's highest-complexity functions, using the tooling from #3431/#3433/#3434. Extract-method refactors only — no behavior change.

Before → after (cyclomatic complexity, measured by tools/code-quality/cfml-complexity.py)

Function Before After
$runOnError (events/EventMethods.cfc) 51 6
paginationLinks (view/links.cfc) 55 23
$initModelClass (Model.cfc) 58 22
renderWith (controller/rendering.cfc) 41 18
$convertToString (global/util.cfm) 43 16
$optionsForSelect (view/formsobject.cfc) 45 9
$dateOrTimeSelect (view/formsdate.cfc) 43 5
$generateTestData (Seeder.cfc) 44 3

Repo-wide: functions over complexity 50 drop 10 → 7; functions at 10 or under rise 2399 → 2416 (+17 small helpers). Every new helper is a public $-prefixed mixin function (private mixins are not integrated on Lucee/Adobe — invariant 7).

How it was done

  • Wave 1 delegated to four parallel subagents (one per file, disjoint targets) with explicit cross-engine invariant rules; Wave 2 (view/controller/seed) done inline. All moves are verbatim statement relocations.
  • The events hardener source-scans (S2/S3/S4 pins) now target the helper that holds each invariant — same live-code guarantees, updated comments.

Verification

  • Complexity gate PASS on both trees; regression + new-hotspot detection intact.
  • Local Lucee 7 + SQLite: model 979/0, view 581/0, controller 529/0, events 87/0, global 219/0, security 290/0, migrator 292/0, hardener 247/0, wheelstest model-expectation 4/0 — all green on a fresh server + fresh DB. (A polluted-DB run first showed unrelated csrf/migrator/callback failures; every one re-passes on a clean DB, and browser specs are skipped locally — Playwright lives in CI.)
  • Cross-engine matrix legs (Adobe 2023 + MySQL, Lucee 7 + MySQL) run before merge per the mixin-change guidance.
  • Full CI suite runs on this PR.

No changelog fragment: pure internal refactor with no user-facing change.

Splits the per-column property/type/mapping setup into
$initModelClassProcessColumn and the automatic validations block into
$initModelClassApplyAutomaticValidations. Statements moved verbatim
(programmatic equivalence check 90/90, 74/74, 16/16); helpers are public
$-prefixed per the mixin integration invariant.

Signed-off-by: Peter Amiri <peter@alurium.com>
… to 3)

$generateTestDataByName holds the pre-type name-pattern checks,
$generateTestDataByType holds the type-based branches in original order.
seederSpec's 50 assertions pin every branch including ordering edges.

Signed-off-by: Peter Amiri <peter@alurium.com>
…41 to 18)

$renderWithNamedArgs derives extra named args from renderWith's own
parameter metadata; $renderWithJsonContent applies the string/integer
coercion directives and serializes. Data mutations propagate through
struct/array pass-by-reference, matching the inline original.

Signed-off-by: Peter Amiri <peter@alurium.com>
Dispatches to $runOnErrorSendEmail, $runOnErrorResolveWheelsError,
$runOnErrorRenderWheelsError, $runOnErrorRenderException, and
$runOnErrorRenderTemplate. The hardener source-scans now target the
helpers that hold each invariant (frozen 404/403/500 map, swallowed
$mail, raw exception serialization) — same live-code guarantees.

Signed-off-by: Peter Amiri <peter@alurium.com>
Seven public $-prefixed global helpers (detect/promote/BoxLang-slash/
struct/number/boolean/datetime) in util.cfm. All branches moved verbatim;
convertToStringSpec and GlobalSurfaceIdentitySpec cover the behavior and
the global surface.

Signed-off-by: Peter Amiri <peter@alurium.com>
…ct, $dateOrTimeSelect

paginationLinks 55 to 23 ($paginationLinkPageArgs, $paginationAnchorLink,
$paginationWindowMiddle); $optionsForSelect 45 to 9 ($optionsForSelectColumns,
$optionsForSelectCell); $dateOrTimeSelect 43 to 5 ($dateOrTimeSelectNormalizeValue,
$dateOrTimeSelectRender). View + security + formsdate specs stay green.

Signed-off-by: Peter Amiri <peter@alurium.com>
The helper returns either {} or a cfcatch/exception object; Adobe 2023's
struct return-type validator rejects the latter (caught by the testing-env
smoke's unknown-route-404 probe). Untyped return matches the original inline
behavior exactly.

Signed-off-by: Peter Amiri <peter@alurium.com>
@bpamiri
bpamiri merged commit 1021907 into develop Aug 28, 2026
11 checks passed
@bpamiri
bpamiri deleted the peter/complexity-burn-down-1 branch August 28, 2026 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant