Commit 3af1762
committed
fix(sonar): collapse _percentile bounds via max/min clamp to silence S2583
Iteration 3: the previous refactor (hoisting clamped_low/clamped_high
into named booleans) still tripped Sonar's S2583 flow analysis on the
second guard at cell_metrics.py:97. Rewrite the function to clamp q
to [0, 1] up front via max(0.0, min(1.0, q)) and dispatch on the
clamped value's equality with 0.0 / 1.0. The boundary returns now sit
on genuinely reachable both-true-and-false equality tests, and Sonar's
narrowing no longer fires.
Semantics preserved: q below 0 returns sorted_values[0], q above 1
returns sorted_values[-1], q in (0, 1) interpolates as before.
Verified locally with q in {-1, 0, 0.5, 1, 2, empty input}.1 parent 35b3480 commit 3af1762
1 file changed
Lines changed: 8 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
| 86 | + | |
| 87 | + | |
87 | 88 | | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
96 | 93 | | |
97 | | - | |
| 94 | + | |
98 | 95 | | |
99 | | - | |
| 96 | + | |
100 | 97 | | |
101 | 98 | | |
102 | 99 | | |
| |||
0 commit comments