Skip to main content

Module god_classes

Module god_classes 

Expand description

god-classes analysis — files combining high cognitive complexity with high coupling (both inbound + outbound). Classic god-class symptom (Brown et al. 1998 AntiPatterns §3.1; Riel 1996 Object-Oriented Design Heuristics).

Consumes the imports table joined with complexity_metrics. fan-in counts files that import THIS file; fan-out counts distinct imports THIS file makes. The composite god_score = (cognitive/100) × (fan_in + fan_out) ranks files where every dimension is pulling up — not just any one.

§Why all three dimensions?

A file with high cognitive complexity but low coupling is just a gnarly algorithm — refactor candidate, not a god class. A file with high fan-out but low cognitive is a thin façade — bus-factor risk, not god class. A file with high fan-in but low cognitive is a utility — the codebase needs it. A god class is all three at once: it’s complex, depends on many things, and many things depend on it. The composite surfaces that intersection.

§Calibration

Defaults: cognitive ≥ 30 (Sonar threshold), fan_in + fan_out ≥ 10. Fan-in accuracy follows the import resolver’s language coverage — languages whose resolver doesn’t yet populate target_path bias the analysis toward fan-out + cognitive.

Structs§

GodClassRow

Functions§

run_god_classes
Run the god-classes analysis. Returns rows ranked by composite god-score (highest first).
run_god_classes_scoped
Run god-classes against caller-supplied source tables. Useful when complexity and import data live in snapshot tables for historical scans.