Reduce cognitive complexity of two burst/drift functions; fix complexipy exclude#694
Merged
ajslater merged 2 commits intov1.11-performancefrom May 2, 2026
Merged
Conversation
Both `CoverCreateThread.process_cover_create_burst` (cognitive 20) and `fix_parent_folder_drift` (cognitive 18, cyclomatic C/13) tripped complexipy's threshold. Split each into focused helpers without changing behavior: - `process_cover_create_burst` -> `_split_pending_pks`, `_render_burst_batch`, `_drain_burst_loop` (now cognitive 4). - `fix_parent_folder_drift` -> `_build_folder_lookups`, `_classify_comic_drift`, `_apply_parent_folder_repoints`, `_log_drift_orphans` (now cognitive 1). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`*/.*` matched too broadly under complexipy's path resolver and ended up excluding every Python file under the configured `paths`, so `make complexity` reported zero functions analyzed even when several exceeded the threshold. Switching to `.*` excludes hidden dotfiles/dirs without nuking the rest of the tree. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
CoverCreateThread.process_cover_create_burst(cognitive 20 → 4) by extracting_split_pending_pks,_render_burst_batch, and_drain_burst_loop.fix_parent_folder_drift(cognitive 18 → 1, cyclomatic C/13 → A/1) by extracting_build_folder_lookups,_classify_comic_drift,_apply_parent_folder_repoints, and_log_drift_orphans.[tool.complexipy] excludeinpyproject.toml:*/.*was matching too broadly and silently excluding every file under the configuredpaths, somake complexitylooked clean while functions with complexity 18 and 20 sat unfixed. Replaced with.*.Why
make complexitywas a false negative — it printedNo function were found with complexity greater than 15because the exclude pattern matched everything, not because the codebase was clean. Once you scan the files individually, two cognitive-complexity violations surface in the v1.11-performance branch. This PR fixes both functions and the exclude bug that hid them.Both refactors are pure structural splits — no behavior change.
Test plan
make complexitypasses (now actually scanning — message changed from singular "No function" to plural "No functions").uv run --group lint complexipy -mx 1 codex/librarian/covers/create.pyconfirmsprocess_cover_create_burstnow reports 4.uv run --group lint complexipy -mx 1 codex/librarian/scribe/janitor/integrity/foreign_keys.pyconfirmsfix_parent_folder_driftno longer appears (cognitive 1).make lintshows no new warnings/errors versus the pre-change branch.from codex.librarian.covers.create import CoverCreateThreadandfrom codex.librarian.scribe.janitor.integrity.foreign_keys import fix_parent_folder_drift, fix_foreign_keysboth succeed.🤖 Generated with Claude Code