Skip to content

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.json generated by the setup skill (source/test roots come from python.paths / Composer autoload; all scripts take --json only, report-only)
  • The scanning scripts at src/zolletta_metaskill/{patterns,code_style,testing_style}/ (or scripts/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

python3 src/zolletta_metaskill/patterns/general/class_metrics_scanner.py

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

python3 src/zolletta_metaskill/patterns/general/test_god_classes_scanner.py --show-methods

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

python3 src/zolletta_metaskill/code_style/python/unused_all_exports_scanner.py

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