refactor(core): split crud/analysis into per-entity modules#726
Merged
Conversation
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.
|
✅ Health: 7.6 (unchanged) 📋 At a glance 🚨 Change risk: high (riskier than 75% of this repo's commits · raw 9.5/10)
🔎 More signals (1)🔥 Hotspot touched (1)
📊 Full report · ⭐ Star Repowise · 📥 Install bot · Last updated 2026-07-08 10:02 UTC |
swati510
approved these changes
Jul 8, 2026
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.
What
crud/analysis.pyhad 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.pydead-code finding persistencehealth.pyhealth findings/metrics/snapshots/governancerefactoring.pyrefactoring-suggestion persistencecoverage.pycoverage-file persistenceThe one cross-entity helper (
_finding_file_path, used by both dead_code and refactoring) moves to the existingcrud/_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__.pyre-exports the public functions with an explicit__all__, so thecrudfacade (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 thecrudnamespace. A grep acrosspackages/,tests/, andscripts/confirmed nothing referenced those leaked names throughcrud, 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.