Complexity reduction#76
Merged
Merged
Conversation
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.