pub fn bus_factor(
knowledge_shares_percent: &[f64],
critical_threshold_percent: f64,
) -> Option<usize>Expand description
The bus factor: the minimum number of people whose combined knowledge
share meets or exceeds critical_threshold_percent (commonly 50.0).
Sorts a copy of knowledge_shares_percent in descending order and
accumulates from the largest share down, counting how many people it
takes to reach the threshold. A low result means knowledge is
dangerously concentrated in a few people; a high result means it is
spread widely.
§Arguments
knowledge_shares_percent— each person’s percentage share of understanding or ownership of the system. Values are assumed to be finite, non-NaN percentages (they need not sum to exactly100.0).critical_threshold_percent— the combined share (e.g.50.0) whose loss is considered critical.
§Returns
The number of people whose combined share reaches the threshold, or
None if knowledge_shares_percent is empty, or if the shares never
reach critical_threshold_percent even after summing all of them.
§Examples
use software_engineering::documentation_and_knowledge_metrics::bus_factor;
// One person alone holds 60%, past the 50% threshold.
assert_eq!(bus_factor(&[60.0, 25.0, 15.0], 50.0), Some(1));
// Five even 20% shares need three of them to cross 50%.
assert_eq!(bus_factor(&[20.0, 20.0, 20.0, 20.0, 20.0], 50.0), Some(3));
assert_eq!(bus_factor(&[], 50.0), None);
// Shares that never reach the threshold even combined.
assert_eq!(bus_factor(&[10.0, 10.0], 50.0), None);