Skip to main content

severity_weighted_finding_score

Function severity_weighted_finding_score 

Source
pub fn severity_weighted_finding_score(counts: &[(FindingSeverity, f64)]) -> f64
Expand description

A severity-weighted static-analysis finding score, so a spike in trivial findings cannot visually swamp a smaller rise in critical ones.

Sum over counts of count × severity_weight(severity).

§Arguments

  • counts — pairs of (severity, count) for the findings being scored.

§Returns

The severity-weighted score. An empty slice sums to 0.0.

§Examples

use software_engineering::static_analysis_metrics::{FindingSeverity, severity_weighted_finding_score};

// One critical finding (weight 5) outweighs four minor ones (weight 1 each = 4).
let critical = severity_weighted_finding_score(&[(FindingSeverity::Critical, 1.0)]);
let many_minor = severity_weighted_finding_score(&[(FindingSeverity::Minor, 4.0)]);
assert!(critical > many_minor);
assert_eq!(severity_weighted_finding_score(&[]), 0.0);