/** * Pass #86: god-class (CWE-1060, category: architecture) * * Detects "God Class" anti-pattern: a class that does too much, is poorly * cohesive, and is heavily coupled to external types. These classes are hard * to test, maintain, and evolve. * * Three CK metrics are computed inline (the metrics pipeline runs separately * and its results are not available here): * * WMC — Weighted Methods per Class: Σ v(G) per method, where v(G) is * McCabe cyclomatic complexity = CFG edges − nodes + 2. * Fallback = 1 per method when CFG data is absent. * * LCOM2 — Lack of Cohesion of Methods (0–1 scale): * (P − Q) / max(1, m*(m−1)/2) * P = method pairs sharing no fields, Q = pairs sharing ≥1 field. * Field access is inferred from DFG defs/uses whose variable name * matches a declared field name (name-match heuristic). * * CBO — Coupling Between Objects: count of distinct external type names * referenced in parameter types, field types, or call receiver_type * within the class, excluding primitives and same-class references. * * A finding is emitted when at least 2 of the 3 thresholds are exceeded: * WMC > 47 (SonarQube default) * LCOM2 > 0.8 * CBO > 14 (SATD threshold) * * Languages: Java, TypeScript, Python. Bash / Rust — skipped. */ import type { AnalysisPass, PassContext } from '../../graph/analysis-pass.js'; export interface GodClassResult { godClasses: Array<{ className: string; line: number; wmc: number; lcom2: number; cbo: number; }>; } export declare class GodClassPass implements AnalysisPass { readonly name = "god-class"; readonly category: "architecture"; run(ctx: PassContext): GodClassResult; /** Compute WMC = Σ v(G) for all methods. v(G) = edges − nodes + 2. */ private computeWMC; /** * Compute LCOM2 = (P − Q) / max(1, m*(m−1)/2) clamped to [0, 1]. * Uses DFG variable names intersected with declared field names. */ private computeLCOM2; /** * Compute CBO = count of distinct external type names referenced in the class. * Sources: call receiver_type, method parameter types, field types. */ private computeCBO; } //# sourceMappingURL=god-class-pass.d.ts.map