[AAASM-3512] ♻️ (dashboard): Fix residual Overview Sonar issues (S3776 + S7780)#1189
Conversation
…S3776) The OverviewPage component was at cognitive complexity 16 (>15) after the KPI extraction — the three loading/error/empty early-return guards were the residual. Extract them into a non-exported overviewGuard() helper so the page reads guard-then-render. Behaviour unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Avoid the escaped backslash in the window-subtitle regex by using a String.raw template — same matched pattern, no escaping. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…igation) The overviewGuard refactor moved the loading/error/empty returns into a helper; the error/empty onRetry/onSecondary/onCta handler arrows were uncovered (codecov/patch). Add two interaction tests: error Retry calls refetch + secondary navigates to /audit; empty CTA → /onboarding, secondary → /agents (asserted via a LocationProbe). OverviewPage.tsx coverage 75%→81%. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Move the loading / error / empty branch logic out of OverviewPage.tsx into a dedicated, independently-testable component module. Keeping it in the page file forced a +31-line insertion that codecov's patch attribution mis-mapped against the prior coverage session; as its own brand-new file the branch coverage is computed cleanly from a single upload. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Drop the inline guard and its now page-only imports; call the extracted OverviewGuard. Behaviour is unchanged — the page still short-circuits to the loading / error / empty states before rendering KPIs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Cover all four guard branches (loading / error / empty / ready) and assert the wired callbacks: Retry refetches, and each secondary/CTA navigates to the right route. Gives the extracted module 100% line and branch coverage. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
🤖 Claude Code —
|



Description
Follow-up to the merged Overview hardening (#1188). The post-merge SonarCloud re-scan surfaced 2 residual Maintainability issues that the first pass introduced/left:
OverviewPage.tsxL190S3776— Cognitive Complexity 16 > 15. Extracted the three loading/error/empty early-return guards into a non-exportedoverviewGuard()helper; the page now reads guard-then-render. Behaviour unchanged.OverviewPage.test.tsxL183S7780— useString.rawfor the window-subtitle regex instead of an escaped backslash.This takes the dashboard SonarCloud Reliability/Maintainability count to 0 (Cost & Budget and Audit Log were already clean post-merge; Overview was the last 2).
Type of Change
How to verify
cd dashboard && pnpm type-check && pnpm lint && pnpm build && pnpm test— all green; Overview suite 31 pass.Related Issues
🤖 Generated with Claude Code