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)
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)