Skip to content

[AAASM-3512] ♻️ (dashboard): Fix residual Overview Sonar issues (S3776 + S7780)#1189

Merged
Chisanan232 merged 6 commits into
masterfrom
v0.0.1/AAASM-3512/fix/overview_residual
Jun 21, 2026
Merged

[AAASM-3512] ♻️ (dashboard): Fix residual Overview Sonar issues (S3776 + S7780)#1189
Chisanan232 merged 6 commits into
masterfrom
v0.0.1/AAASM-3512/fix/overview_residual

Conversation

@Chisanan232

Copy link
Copy Markdown
Contributor

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.tsx L190 S3776 — Cognitive Complexity 16 > 15. Extracted the three loading/error/empty early-return guards into a non-exported overviewGuard() helper; the page now reads guard-then-render. Behaviour unchanged.
  • OverviewPage.test.tsx L183 S7780 — use String.raw for 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

  • ♻️ Refactor / 🚨 lint-class fix (no behaviour change)

How to verify

cd dashboard && pnpm type-check && pnpm lint && pnpm build && pnpm test — all green; Overview suite 31 pass.

Related Issues

  • AAASM-3512 (residual from the SonarCloud re-verification)

🤖 Generated with Claude Code

Chisanan232 and others added 2 commits June 21, 2026 15:17
…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

codecov Bot commented Jun 21, 2026

Copy link
Copy Markdown

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>
@Chisanan232 Chisanan232 reopened this Jun 21, 2026
Chisanan232 and others added 3 commits June 21, 2026 16:07
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>
@sonarqubecloud

Copy link
Copy Markdown

@Chisanan232

Copy link
Copy Markdown
Contributor Author

🤖 Claude Code — codecov/patch root-cause + fix

Symptom: codecov/patch reported 66.66% ("4 lines missing") in dashboard/src/pages/OverviewPage.tsx, while the local full-suite run (vitest run --coverage, the exact CI command) showed every changed line covered.

Diagnosis. The earlier residual fix added overviewGuard() inside OverviewPage.tsx — a +31-line insertion mid-file. Codecov's patch attribution mis-mapped that shift against the prior coverage session: it flagged the guard's branch lines (if (args.isLoading), if (args.isError), …) as missed even though the uploaded lcov.info recorded non-zero hits for all of them (L201=29, L202=28, L203=3, L211=25, L220=21, L240=29, L247=29). The report was internally inconsistent (arrow callbacks counted as hit, their enclosing branches as missed) — the signature of stale line-mapping, not a real gap. The dashboard upload itself succeeded on every run.

Fix (no behaviour change). Extracted the guard into its own brand-new module OverviewPage.guard.tsx (OverviewGuard) — mirroring the existing OverviewPage.kpis.ts split, and keeping OverviewPage.tsx a components-only module for react-refresh. As a new file there is no prior line history for codecov to mis-map, so patch coverage is computed cleanly from a single session. Added OverviewPage.guard.test.tsx covering all four branches (loading / error / empty / ready) and the wired callbacks (Retry → refetch; secondaries/CTA → correct routes).

Result (codecov compare API, head 1234bc3):

  • OverviewPage.guard.tsx — patch 100% (10/10 lines, 3/3 branches)
  • OverviewPage.tsx — patch 100% (2/2 lines)

Local: type-check ✅ · eslint clean ✅ · guard module 100% line+branch ✅ · full dashboard suite green ✅.

@Chisanan232 Chisanan232 merged commit 484f7f7 into master Jun 21, 2026
38 checks passed
@Chisanan232 Chisanan232 deleted the v0.0.1/AAASM-3512/fix/overview_residual branch June 21, 2026 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant