Skip to content

refactor(core): split crud/analysis into per-entity modules#726

Merged
swati510 merged 1 commit into
mainfrom
split/crud-analysis-package
Jul 8, 2026
Merged

refactor(core): split crud/analysis into per-entity modules#726
swati510 merged 1 commit into
mainfrom
split/crud-analysis-package

Conversation

@RaghavChamadiya

Copy link
Copy Markdown
Member

What

crud/analysis.py had grown to ~1168 lines mixing CRUD for four unrelated entities behind one flat module: dead-code findings, code-health (findings/metrics/snapshots/governance), refactoring suggestions, and coverage files.

This splits it into a crud/analysis/ package grouped by entity:

  • dead_code.py dead-code finding persistence
  • health.py health findings/metrics/snapshots/governance
  • refactoring.py refactoring-suggestion persistence
  • coverage.py coverage-file persistence

The one cross-entity helper (_finding_file_path, used by both dead_code and refactoring) moves to the existing crud/_shared.py.

Why

Each entity's persistence is now an isolated module rather than one long file where four tables' queries are interleaved.

Safety

Pure structural move: every function relocates verbatim and the three lazy imports in the health functions stay function-local. __init__.py re-exports the public functions with an explicit __all__, so the crud facade (from .analysis import *) and the direct test importers keep the same public surface.

One deliberate cleanup: the previous module had no __all__, so its star-export incidentally leaked ORM model names (DeadCodeFinding, select, etc.) into the crud namespace. A grep across packages/, tests/, and scripts/ confirmed nothing referenced those leaked names through crud, so the explicit __all__ narrows the star-export to just the intended public functions. No caller is affected.

Verified: the full persistence test suite (264 tests) passes.

crud/analysis.py had grown to ~1168 lines mixing CRUD for four unrelated
entities behind one flat module: dead-code findings, code-health
(findings/metrics/snapshots), refactoring suggestions, and coverage
files.

Split it into a crud/analysis/ package grouped by entity:

- dead_code.py    dead-code finding persistence
- health.py       health findings/metrics/snapshots/governance
- refactoring.py  refactoring-suggestion persistence
- coverage.py     coverage-file persistence

The one cross-entity helper (_finding_file_path, used by both dead_code
and refactoring) moves to the existing crud/_shared.py. Pure structural
move: every function relocates verbatim and the three lazy imports in the
health functions stay function-local.

__init__.py re-exports the public functions with an explicit __all__, so
the crud facade (from .analysis import *) and the direct test importers
keep the same public surface. A grep confirmed nothing relied on the ORM
model names that the previous no-__all__ star-export incidentally leaked
through the crud namespace.
@RaghavChamadiya RaghavChamadiya requested a review from swati510 as a code owner July 8, 2026 10:01
@repowise-bot

repowise-bot Bot commented Jul 8, 2026

Copy link
Copy Markdown

✅ Health: 7.6 (unchanged)

📋 At a glance
1 hotspot touched · 11 new findings introduced. Scoped to packages.

🚨 Change risk: high (riskier than 75% of this repo's commits · raw 9.5/10)
This change's risk is driven by:

  • more lines added than baseline
  • more scattered than baseline
🔎 More signals (1)

🔥 Hotspot touched (1)

  • .../crud/_shared.py — 3 commits/90d, 6 dependents · primary owner: Swati Ahuja (56%)

📊 Full report · ⭐ Star Repowise · 📥 Install bot · Last updated 2026-07-08 10:02 UTC
Silence on a single PR with [skip repowise] in the title · Per-repo toggle on repowise.dev/settings?tab=bot

@swati510 swati510 merged commit 06d860e into main Jul 8, 2026
7 checks passed
@swati510 swati510 deleted the split/crud-analysis-package branch July 8, 2026 10:10
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.

2 participants