Combines two related findings from a codebase audit (B3, B8) — same code, same fix.
Problem
B3: In `src/components/plots/EquilibriumPlot.tsx` (lines 50–84, 135–136), when no equilibrium data has been recorded yet, `x = []`. `Math.max(...[])` returns `-Infinity` and `Math.min(...[])` returns `Infinity`, used as Y-axis positions for reference lines. The `bestFit` regression is also computed on empty data (`regression.logarithmic([])`) before the `x.length >= 3` guard exists, which can throw or return NaN/garbage.
B8: The `bestFit` `useMemo` (same lines) always runs `regression.logarithmic`/`regression.exponential` before checking `bestFitVisible = x.length >= 3` — the expensive/unsafe computation runs unconditionally on every render regardless of whether there's enough data to use it.
Severity: High (B3) / Medium (B8)
Fix
Guard all trace/line construction and the regression computation with `x.length >= 3` (the same threshold the component already uses to decide whether to display the result) before computing min/max and running regression. Return a safe empty/default result early if there isn't enough data.
🤖 Filed via Claude Code from a codebase audit.
Combines two related findings from a codebase audit (B3, B8) — same code, same fix.
Problem
B3: In `src/components/plots/EquilibriumPlot.tsx` (lines 50–84, 135–136), when no equilibrium data has been recorded yet, `x = []`. `Math.max(...[])` returns `-Infinity` and `Math.min(...[])` returns `Infinity`, used as Y-axis positions for reference lines. The `bestFit` regression is also computed on empty data (`regression.logarithmic([])`) before the `x.length >= 3` guard exists, which can throw or return NaN/garbage.
B8: The `bestFit` `useMemo` (same lines) always runs `regression.logarithmic`/`regression.exponential` before checking `bestFitVisible = x.length >= 3` — the expensive/unsafe computation runs unconditionally on every render regardless of whether there's enough data to use it.
Severity: High (B3) / Medium (B8)
Fix
Guard all trace/line construction and the regression computation with `x.length >= 3` (the same threshold the component already uses to decide whether to display the result) before computing min/max and running regression. Return a safe empty/default result early if there isn't enough data.
🤖 Filed via Claude Code from a codebase audit.