Skip to content

Complexity reduction#76

Merged
rowlesmr merged 15 commits into
mainfrom
complexity
Jun 14, 2026
Merged

Complexity reduction#76
rowlesmr merged 15 commits into
mainfrom
complexity

Conversation

@rowlesmr

Copy link
Copy Markdown
Owner

Complexity reduction: eliminate all F-grade and E-grade functions

Decomposed 13 high-complexity functions into focused private helpers, each preceded by branch-coverage tests. No
behaviour was changed — all 2076 tests pass. Xenon --max-absolute D passes except for one irreducible E-grade function
(_resolve_fk_group, the FK resolution core).

F-grade → resolved (7 functions):

┌─────────────────────┬────────┬───────┐
│ Function │ Before │ After │
├─────────────────────┼────────┼───────┤
│ _collect_grouped │ 170 │ D/26 │
├─────────────────────┼────────┼───────┤
│ generate_schema │ 98 │ A/2 │
├─────────────────────┼────────┼───────┤
│ _render_block │ 69 │ C/14 │
├─────────────────────┼────────┼───────┤
│ inspect_schema │ 61 │ A/1 │
├─────────────────────┼────────┼───────┤
│ visualise_schema │ 55 │ B/7 │
├─────────────────────┼────────┼───────┤
│ _render_merge_group │ 54 │ D/21 │
├─────────────────────┼────────┼───────┤
│ _collect_all_blocks │ 45 │ B/7 │
└─────────────────────┴────────┴───────┘

E-grade → resolved (6 of 7; one irreducible):

┌───────────────────────────────────┬────────┬───────────────────────────┐
│ Function │ Before │ After │
├───────────────────────────────────┼────────┼───────────────────────────┤
│ _run_fk_fill_pass │ E/39 │ A │
├───────────────────────────────────┼────────┼───────────────────────────┤
│ _render_original_loop_group │ E/38 │ C/15 │
├───────────────────────────────────┼────────┼───────────────────────────┤
│ propagate_fk_sql │ E/36 │ A │
├───────────────────────────────────┼────────┼───────────────────────────┤
│ consolidate_component_intensities │ E/33 │ B/7 │
├───────────────────────────────────┼────────┼───────────────────────────┤
│ _collect_structure │ E/32 │ A │
├───────────────────────────────────┼────────┼───────────────────────────┤
│ _render_set_category │ E/31 │ A │
├───────────────────────────────────┼────────┼───────────────────────────┤
│ _resolve_fk_group │ E/33 │ E/33 — irreducible, leave │
└───────────────────────────────────┴────────┴───────────────────────────┘

Tests: 1858 → 2076 (+218), all passing.

rowlesmr added 15 commits June 12, 2026 20:32
   Decompose _collect_grouped (CC 170, F-grade) into 12 module-level helpers,
   eliminating the nested _block_fingerprint and _fp_entries_for_expanded closures
   that were inflating radon's measurement of the outer function.

   New helpers: _collect_set_pk_vals, _fp_entries_for_expanded,
   _drop_incidental_child_sets, _compute_block_fingerprint,
   _compute_no_set_fk_routing, _collect_fp_table_rows, _compute_fp_anchor,
   _compute_primary_fp_anchors, _collect_incidental_block_rows,
   _bfs_collect_child_sets, _build_grouped_state, _emit_pure_loop_blocks.

   _collect_grouped: F/170 -> D/26.  _collect_incidental_block_rows: C/18.
   All pre-existing xenon violations unchanged; no new violations introduced.

   29 branch-coverage tests added in tests/output/test_collect_grouped.py.
   Suite: 1951 -> 1980 passed.
   Extract helpers from two E-grade ingest functions:
   - propagate_fk_sql (E/36 → A): extracted _generate_uuid_pks, _create_composite_fk_stub_parents,
   _create_single_fk_stub_parents
   - _run_fk_fill_pass (E/39 → A): extracted _fill_single_fk, _fill_composite_fk, _fill_propagation_links

   28 branch-coverage tests added (suite: 1980 → 2008).
@rowlesmr rowlesmr merged commit c46b5ba into main Jun 14, 2026
16 checks passed
@rowlesmr rowlesmr deleted the complexity branch June 15, 2026 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant