Now I have a complete view of all the large files. Let me analyze each one for natural decomposition points.
Analysis Complete
Here's my decomposition analysis for each file:
1. desloppify/lang/python/detectors/smells.py (1148 LOC)
Natural split: Extract AST-based detectors to separate module
Logical groups:
- Regex-based smell detection (lines 14-62, 176-234): Pattern definitions + regex matching
- Multi-line string helpers (lines 65-174): String parsing utilities
- Except-block analysis (lines 236-283): Specialized multi-line detectors
- AST-based detectors (lines 286-1148): 20+ AST visitor functions
Split recommendation:
- Keep in smells.py (~400 LOC): SMELL_CHECKS registry, detect_smells() orchestrator, regex-based detectors, string helpers, except-block walkers
- Extract to
smells_ast.py (~750 LOC): All AST detector functions (_detect_monster_functions, _detect_dead_functions, _detect_deferred_imports, _detect_subprocess_no_timeout, _detect_mutable_class_var, _detect_lru_cache_mutable, _detect_unsafe_file_write, _detect_unreachable_code, _detect_constant_return, _detect_regex_backtrack, _detect_naive_comment_strip, _detect_callback_logging, _detect_hardcoded_path_sep, _detect_lost_exception_context, _detect_vestigial_parameter, _detect_noop_function, _collect_module_constants, _detect_duplicate_constants)
Imports affected: 1 (smells.py imports from smells_ast)
2. desloppify/detectors/test_coverage.py (836 LOC)
Natural split: Extract import resolution/test quality analysis
Logical groups:
- Core detection logic (lines 1-151): Main API, LOC helpers, testable logic checks
- Import-based mapping (lines 314-431): Parse imports, resolve TS paths, barrel expansion
- Naming convention mapping (lines 473-566): Test file name → source file heuristics
- Transitive coverage (lines 568-592): BFS through dep graph
- Test quality analysis (lines 594-680): Assertion/mock/snapshot counting
- Finding generation (lines 682-836): Build finding dicts from analysis results
Split recommendation:
- Keep in test_coverage.py (~400 LOC): detect_test_coverage() orchestrator, _file_loc, _has_testable_logic, _no_tests_findings, _generate_findings, _transitive_coverage
- Extract to
test_coverage_mapping.py (~440 LOC): All import resolution (_import_based_mapping, _parse_test_imports, _resolve_ts_import, _resolve_barrel_reexports, _naming_based_mapping, _map_test_to_source, _strip_test_markers) + test quality analysis (_analyze_test_quality, _strip_py_comment, _get_test_files_for_prod)
Imports affected: 1 (test_coverage.py imports from test_coverage_mapping)
3. desloppify/review/context.py (753 LOC)
Natural split: Extract holistic context builder
Logical groups:
- ReviewContext dataclass + shared helpers (lines 1-72): Data structure, filepath utils, graph lookups
- Per-file review context (lines 119-267): build_review_context() + _build_review_context_inner()
- Heuristic signal gatherers (lines 290-514): AI debt, auth patterns, migration signals
- Holistic context builder (lines 536-753): build_holistic_context() + _build_holistic_context_inner()
Split recommendation:
- Keep in context.py (~350 LOC): ReviewContext, shared helpers, per-file review context builder (build_review_context + _build_review_context_inner), _serialize_context, _gather_ai_debt_signals, _gather_auth_context, _classify_error_strategy
- Extract to
context_holistic.py (~400 LOC): build_holistic_context() + _build_holistic_context_inner() + _gather_migration_signals() — all the codebase-wide aggregation logic
Imports affected: 2 (context.py imports from context_holistic; review dimension modules import from context.py)
4. desloppify/lang/typescript/detectors/_smell_helpers.py (680 LOC)
Natural split: Extract brace-tracking detectors
Logical groups:
- String scanning + comment stripping (lines 1-120): _scan_code, _strip_ts_comments, _ts_match_is_in_string
- Multi-line smell detectors (lines 122-253): async_no_await, error_no_throw, empty_if_chains
- useEffect/function analysis (lines 255-532): dead_useeffects, monster_functions, dead_functions
- Specialized smell detectors (lines 534-680): window_globals, catch_return_default, switch_no_default
Split recommendation:
- Keep in _smell_helpers.py (~280 LOC): _scan_code, _strip_ts_comments, _ts_match_is_in_string, _track_brace_body, _find_function_start (shared utilities)
- Extract to
_smell_detectors.py (~400 LOC): All 9 detector functions (_detect_async_no_await, _detect_error_no_throw, _detect_empty_if_chains, _detect_dead_useeffects, _detect_monster_functions, _detect_dead_functions, _detect_window_globals, _detect_catch_return_default, _detect_switch_no_default)
Imports affected: 1 (smells.py imports from both _smell_helpers and _smell_detectors)
5. desloppify/lang/python/detectors/dict_keys.py (613 LOC)
Natural split: Extract visitor into separate module
Logical groups:
- Data structures + helpers (lines 1-66): TrackedDict, Levenshtein, singular/plural checks
- DictKeyVisitor AST walker (lines 68-474): 300+ LOC single class
- Pass 1: Single-scope analysis (lines 476-501): detect_dict_key_flow() runner
- Pass 2: Schema drift (lines 504-613): Jaccard clustering, cross-file analysis
Split recommendation:
- Keep in dict_keys.py (~250 LOC): TrackedDict dataclass, helper functions, detect_dict_key_flow(), detect_schema_drift()
- Extract to
dict_keys_visitor.py (~360 LOC): DictKeyVisitor class (entire AST walker with all its methods)
Imports affected: 1 (dict_keys.py imports DictKeyVisitor from dict_keys_visitor)
6. desloppify/lang/typescript/init.py (600 LOC)
Natural split: Extract phase runners
Logical groups:
- Config data + signals (lines 1-83): Imports, complexity signals, god rules, zone rules
- Phase runners (lines 85-459): 8 phase functions (_phase_logs, _phase_unused, _phase_exports, _phase_deprecated, _phase_structural, _phase_coupling, _phase_smells, _make_boundary_findings)
- Fixer registry (lines 463-533): _get_ts_fixers()
- TypeScriptConfig class (lines 536-600): LangConfig instantiation
Split recommendation:
- Keep in init.py (~300 LOC): Config constants, _get_ts_fixers(), TypeScriptConfig class definition, _ts_build_dep_graph, _ts_extract_functions
- Extract to
phases.py (~300 LOC): All 8 phase runner functions + _make_boundary_findings helper
Imports affected: 1 (init.py imports phase runners from phases)
7. desloppify/visualize.py (586 LOC)
Natural split: Extract HTML template + rendering
Logical groups:
- Data collection (lines 1-87): _collect_file_data, _build_tree
- Generation API (lines 89-160): generate_visualization, cmd_viz
- Text tree (lines 162-309): _aggregate, _print_tree, generate_tree_text, cmd_tree
- HTML template (lines 311-586): 275-line HTML/CSS/JS string
Split recommendation:
- Keep in visualize.py (~310 LOC): All Python code (data collection, generation, text tree, cmd functions)
- Extract to
_template.html (275 LOC): Entire HTML template as a separate file, loaded via read_text()
Imports affected: 1 (visualize.py reads template from _template.html)
8. desloppify/scorecard.py (543 LOC)
Natural split: Extract drawing functions
Logical groups:
- Helper functions (lines 1-127): Color, font loading, formatting, ornaments, project name
- Drawing primitives (lines 180-323): _draw_left_panel, _draw_right_panel
- Main generation (lines 421-543): generate_scorecard, get_badge_config
Split recommendation:
- Keep in scorecard.py (~280 LOC): generate_scorecard(), get_badge_config(), _get_project_name(), _score_color(), _load_font(), palette constants
- Extract to
_scorecard_draw.py (~260 LOC): All drawing helper functions (_s, _fmt_score, _draw_ornament, _draw_rule_with_ornament, _draw_vert_rule_with_ornament, _draw_left_panel, _draw_right_panel)
Imports affected: 1 (scorecard.py imports drawing functions from _scorecard_draw)
9. desloppify/review/dimensions.py (527 LOC)
Natural split: Extract prompts from system prompts
Logical groups:
- Holistic dimensions data (lines 1-179): HOLISTIC_DIMENSIONS list + HOLISTIC_DIMENSION_PROMPTS dict
- Holistic system prompt (lines 181-251): 70-line multi-paragraph prompt string
- Review dimensions data (lines 254-413): DEFAULT_DIMENSIONS list + DIMENSION_PROMPTS dict + LANG_GUIDANCE dict
- Review system prompt (lines 456-526): 70-line multi-paragraph prompt string
Split recommendation:
- Keep in dimensions.py (~280 LOC): All dimension lists and prompt dicts (HOLISTIC_DIMENSIONS, HOLISTIC_DIMENSION_PROMPTS, DEFAULT_DIMENSIONS, DIMENSION_PROMPTS, LANG_GUIDANCE)
- Extract to
prompts.py (~250 LOC): Just the two large system prompt strings (HOLISTIC_REVIEW_SYSTEM_PROMPT, REVIEW_SYSTEM_PROMPT)
Imports affected: 2 (dimensions.py imports from prompts; review modules import from dimensions)
10. desloppify/lang/base.py (533 LOC)
Natural split: Extract finding factories
Logical groups:
- Dataclasses (lines 1-105): DetectorPhase, FixResult, FixerConfig, BoundaryRule, LangConfig
- Finding factory functions (lines 108-403): 15 make_*_findings functions
- Shared phase runners (lines 406-533): find_external_test_files, phase_security, phase_test_coverage, phase_subjective_review
Split recommendation:
- Keep in base.py (~270 LOC): All dataclasses, shared phase runners (phase_security, phase_test_coverage, phase_subjective_review, find_external_test_files)
- Extract to
finding_factories.py (~260 LOC): All 15 finding factory functions (make_unused_findings, make_dupe_findings, add_structural_signal, merge_structural_signals, make_single_use_findings, make_cycle_findings, make_orphaned_findings, make_smell_findings, make_passthrough_findings, make_facade_findings, SMELL_TIER_MAP)
Imports affected: 3-4 (base.py imports from finding_factories; all lang plugins import from base)
Summary Table
| File | Current LOC | Split 1 | Split 2 | Imports Affected |
|---|
| smells.py | 1148 | 400 | 750 | 1 |
| test_coverage.py | 836 | 400 | 440 | 1 |
| context.py | 753 | 350 | 400 | 2 |
| _smell_helpers.py | 680 | 280 | 400 | 1 |
| dict_keys.py | 613 | 250 | 360 | 1 |
| typescript/init.py | 600 | 300 | 300 | 1 |
| visualize.py | 586 | 310 | 275 | 1 |
| scorecard.py | 543 | 280 | 260 | 1 |
| dimensions.py | 527 | 280 | 250 | 2 |
| base.py | 533 | 270 | 260 | 3-4 |
All splits follow natural logical boundaries and would result in both files being under 500 LOC (most under 400).