SOL-PMAT-001 // pmat

Cyclomatic & Cognitive Complexity Gate

Enforce strict Cyclomatic <= 30 and Cognitive <= 25 budgets across Rust workspaces in pre-commit and CI pipelines.

Measured delta: Max cognitive complexity cut from 28 -> 2 (Cyclomatic <= 30)

Cyclomatic & Cognitive Complexity Gate receipt poster
Verified CLI Version
pmat 3.47.0
Receipt SHA-256
61b896afef342cb0a11491c1d90e705f5b6e32acfa82fbc8b06d8ffa7db003e7

Before (Failing Anti-Pattern)

pub fn check_all(a: bool, b: bool, c: bool, n: usize) -> bool {
    if a { if b { if c { n < 10 } else { n < 20 } } else { false } } else { true }
}

After (Verified Code)

pub fn validate_budget(bytes: usize, limit: usize) -> Result<(), String> {
    if bytes > limit {
        return Err(format!("budget exceeded: {bytes} > {limit}"));
    }
    Ok(())
}

Verification Contract

schema: pmat.quality-gate.v1
max_cyclomatic: 30
max_cognitive: 25
max_satd: 0
fail_on_violation: true

Verified CLI Command & Output

$ pmat analyze complexity --max-cyclomatic 30 --max-cognitive 25 --path site
pmat: 0 functions exceeding thresholds (max cyclomatic=8, max cognitive=16)