Detect God classes and structural design issues¶
Paths in this document are relative to the Zolletta-MetaSkill project root.
Identify God classes, missing tests, dependency-inversion violations, and other structural design problems in an object-oriented codebase using the Zolletta-metaskill patterns workflow. The approach is two-phase: automated triage with scanning scripts, then principle-based judgment to distinguish true God classes from long-but-cohesive classes.
Prerequisites¶
- A configured project —
.zolletta-metaskill/settings.jsongenerated by the setup skill (source/test roots come frompython.paths/ Composer autoload; all scripts take--jsononly, report-only) - The scanning scripts at
src/zolletta_metaskill/{patterns,code_style,testing_style}/(orscripts/python/in the baseline layout)
Phase 1 — Automated triage¶
Run the scanning scripts to get a structural overview. Each script produces a markdown report with candidates sorted by severity.
Step 1 — Class metrics¶
This lists the largest classes by line count, with method count, public method count, and self.* attribute count. Classes with many attributes and methods are God class candidates. Tune with python.patterns.class_metrics_top / class_metrics_min_lines.
Step 2 — Test God classes¶
This finds test classes that test multiple unrelated SUTs. Use --show-methods to see the method names and spot mixed SUTs.
Step 3 — SOLID violations¶
# Dependency Inversion (DIP)
python3 src/zolletta_metaskill/patterns/python/dependency_inversion_scanner.py
# Interface Segregation (ISP)
python3 src/zolletta_metaskill/patterns/python/interface_segregation_scanner.py
# Liskov Substitution (LSP)
python3 src/zolletta_metaskill/patterns/general/liskov_substitution_scanner.py
# Open/Closed (OCP)
python3 src/zolletta_metaskill/patterns/python/open_closed_scanner.py
Step 4 — Structural conventions¶
# One class per file + filename matches class
python3 src/zolletta_metaskill/code_style/general/one_class_per_file_scanner.py
python3 src/zolletta_metaskill/code_style/general/naming_conventions_scanner.py
# Test directory mirrors source directory
python3 src/zolletta_metaskill/testing_style/general/test_structure_scanner.py
Step 5 — Dead code¶
Phase 2 — Judgment¶
Apply the "reason to change" test from general-principles.md → God Class Detection → Procedure.
Suppress false positives per false-positive-prevention.md → Rule 1 (mandatory judgment step) and Rule 2 (coverage cross-check).
See also¶
- General principles — SOLID and other fundamental principles
- False-positive prevention — three mechanisms to avoid false positives
- Structural conventions — one class per file, test mirroring, naming
- Scripts reference — full reference for all scanning scripts
- Split a God test class — how to split a test class that tests multiple SUTs