Skip to content

Reduce cognitive complexity of two burst/drift functions; fix complexipy exclude#694

Merged
ajslater merged 2 commits intov1.11-performancefrom
claude/distracted-jang-5dbb15
May 2, 2026
Merged

Reduce cognitive complexity of two burst/drift functions; fix complexipy exclude#694
ajslater merged 2 commits intov1.11-performancefrom
claude/distracted-jang-5dbb15

Conversation

@ajslater
Copy link
Copy Markdown
Owner

@ajslater ajslater commented May 2, 2026

Summary

  • Refactor CoverCreateThread.process_cover_create_burst (cognitive 20 → 4) by extracting _split_pending_pks, _render_burst_batch, and _drain_burst_loop.
  • Refactor 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.
  • Fix [tool.complexipy] exclude in pyproject.toml: */.* was matching too broadly and silently excluding every file under the configured paths, so make complexity looked clean while functions with complexity 18 and 20 sat unfixed. Replaced with .*.

Why

make complexity was a false negative — it printed No function were found with complexity greater than 15 because 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 complexity passes (now actually scanning — message changed from singular "No function" to plural "No functions").
  • uv run --group lint complexipy -mx 1 codex/librarian/covers/create.py confirms process_cover_create_burst now reports 4.
  • uv run --group lint complexipy -mx 1 codex/librarian/scribe/janitor/integrity/foreign_keys.py confirms fix_parent_folder_drift no longer appears (cognitive 1).
  • make lint shows no new warnings/errors versus the pre-change branch.
  • Smoke import: from codex.librarian.covers.create import CoverCreateThread and from codex.librarian.scribe.janitor.integrity.foreign_keys import fix_parent_folder_drift, fix_foreign_keys both succeed.

🤖 Generated with Claude Code

ajslater and others added 2 commits May 1, 2026 21:06
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>
@ajslater ajslater merged commit 0e280e6 into v1.11-performance May 2, 2026
1 check failed
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