Skip to main content

apply_percentile

Function apply_percentile 

Source
pub fn apply_percentile(stats: &mut [Stats])
Available on crate feature vcs-git only.
Expand description

Recompute every file’s risk_score as the mean percentile rank of its signals within the analyzed set (the --risk-formula percentile mode).

Each signal is ranked independently using the mid-rank of ties (so identical values share a percentile), scaled to [0, 100], and the per-file mean across signals becomes the score. With fewer than two files percentiles are undefined, so the weighted score is left in place.

The u64 → f64 signal casts are exact for every realistic churn count (well under 2^53) and the result is ordinal, so the precision lint is allowed for the whole pass.

The resulting risk_score is stamped with and cache-keyed on RISK_SCORE_VERSION (the same constant as the weighted formula), so any change to this blend — the extractor set, the mid-rank scaling, or the / signal_count * 100 normalization — must increment that constant.