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 codebase with
src/andtests/directories (scripts use theastmodule — no code execution required) - 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.
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/dependency_inversion_scanner.py src
# Interface Segregation (ISP)
python3 src/zolletta_metaskill/patterns/interface_segregation_scanner.py src --min-methods 5
# Liskov Substitution (LSP)
python3 src/zolletta_metaskill/patterns/liskov_substitution_scanner.py src
# Open/Closed (OCP)
python3 src/zolletta_metaskill/patterns/open_closed_scanner.py src
Step 4 — Structural conventions¶
# One class per file + filename matches class
python3 src/zolletta_metaskill/code_style/general/one_class_per_file_scanner.py src
python3 src/zolletta_metaskill/code_style/general/naming_conventions_scanner.py --src src --tests tests
# Test directory mirrors source directory
python3 src/zolletta_metaskill/testing_style/general/test_structure_scanner.py --src src --tests tests
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