Skip to main content

severity_weight

Function severity_weight 

Source
pub fn severity_weight(severity: FindingSeverity) -> f64
Expand description

The fixed weight applied to a finding of a given severity in severity_weighted_finding_score: Critical = 5.0, Major = 3.0, Minor = 1.0 — the same weighting convention this crate uses for escaped defects, so a spike in trivial findings can’t visually swamp a smaller but more consequential rise in critical ones.

§Arguments

  • severity — the finding severity to weight.

§Returns

The fixed weight for that severity.

§Examples

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

assert!((severity_weight(FindingSeverity::Critical) - 5.0).abs() < 1e-9);
assert!((severity_weight(FindingSeverity::Major) - 3.0).abs() < 1e-9);
assert!((severity_weight(FindingSeverity::Minor) - 1.0).abs() < 1e-9);