Skip to main content

fallow_types/
results_component_health.rs

1use super::AnalysisResults;
2
3macro_rules! enforced_component_count {
4    ($findings:expr) => {{
5        let findings = $findings;
6        let mut count = 0;
7        let mut index = 0;
8        while index < findings.len() {
9            if matches!(
10                findings.as_slice()[index].effective_severity,
11                Some(crate::output_dead_code::EffectiveSeverity::Error)
12            ) {
13                count += 1;
14            }
15            index += 1;
16        }
17        count
18    }};
19}
20
21/// Component health arrays that contribute to totals only at explicit error severity.
22pub const ERROR_ONLY_RESULT_KEYS: &[&str] = &[
23    "prop_drilling_chains",
24    "thin_wrappers",
25    "duplicate_prop_shapes",
26];
27
28impl AnalysisResults {
29    /// Prop-drilling chains that explicitly enforce the error policy.
30    /// Advisory warnings stay outside totals used by strict CI count gates.
31    #[must_use]
32    pub const fn enforced_prop_drilling_count(&self) -> usize {
33        enforced_component_count!(&self.prop_drilling_chains)
34    }
35
36    /// Thin wrappers whose saved severity explicitly enforces error policy.
37    #[must_use]
38    pub const fn enforced_thin_wrapper_count(&self) -> usize {
39        enforced_component_count!(&self.thin_wrappers)
40    }
41
42    /// Duplicate prop shapes whose saved severity explicitly enforces error policy.
43    #[must_use]
44    pub const fn enforced_duplicate_prop_shape_count(&self) -> usize {
45        enforced_component_count!(&self.duplicate_prop_shapes)
46    }
47}