Skip to content

CLI-1703 Extract shared stats rendering helpers - #1394

Merged
Krosovok merged 1 commit into
masterfrom
feat/krosovok/CLI-1703-extractStatsHelpers
Nov 26, 2026
Merged

Krosovok merged 1 commit into
masterfrom
feat/krosovok/CLI-1703-extractStatsHelpers

Conversation

@sonar-fabrik

@sonar-fabrik sonar-fabrik Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

CLI-1703 https://sonarsource.atlassian.net/browse/CLI-1703

Human description

Stats rendering helpers were private to the text report. Other stats files can now import the summary card, bar, sparkline and aligned totals layout. The text output stays the same.

Agent description

Approach: Move the existing rendering logic to one stats-local module. Keep section rendering and entitlement resolution in the report. Export the widths used by both modules so their alignment stays consistent. No options or data models change.

Acceptance coverage: The helpers are importable. Thirteen unit cases cover charts, alignment, time windows, entitlement placeholders and daily bucketing. Six output snapshots pass against both the original implementation and the extracted helpers. All fourteen existing stats integration tests pass. Type checking, lint and formatting pass. Full platform suites remain to current-head CI.

Vortex: Project SonarSource_sonarqube-cli is bound, with context and analysis enabled. Vortex supplied project guidelines and TypeScript guidance for complexity, types and tests. The extraction preserves dependency direction and uses type-only imports. DEEP analysis found no issues. Changed-file secrets scanning found no secrets. Dependency scanning found sixteen existing risks, including deliberately vulnerable E2E fixtures. No manifest or lockfile changes are included.

Decision record: none required or changed. The implementation follows the bounded extraction plan. Human approval and merge remain required.

Assumptions and warnings: Interpret short/full as the existing rendering consumers; this change adds no new view. The linked Confluence refinement was unavailable, so the explicit unchanged-output criteria define this refactor. Reviewers can correct that interpretation if needed. Root agent instructions exist, but the repository has no ADR directory; no guidance files are added. Dependency risks remain outside this refactor.

Validation gaps: The restricted independent-review sandbox could not reproduce eight scanner-dependent integration cases because scanner or hook setup failed. All fourteen cases passed in both the task workspace and clean host preparation at this head. Preserve that host evidence and confirm scanner coverage in current-head CI. Full platform tests and the repository Sonar gate await CI.

Attachments used: none; the refreshed inventory is complete and empty.

Independent review: clean, round 1, gpt-6.1-sol, zero blocking findings. The reviewer independently passed thirteen helper tests, six snapshots, type checking and focused lint.
Usage: gpt-6.1-sol, 4,553,250 processed tokens across run sessions, including 525,960 review tokens. These are measured processing totals, not billing.

This PR was opened as a draft by the autonomous Fabrik workflow. Keep draft per the ticket's fabrik-keep-draft label. The requester will mark it ready after all mechanical gates pass. Human approval and merge are required.


🤖 Co-authored by Fabrik

@netlify

netlify Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for sonarqube-cli canceled.

Name Link
🔨 Latest commit 6fb2222
🔍 Latest deploy log https://app.netlify.com/projects/sonarqube-cli/deploys/6b06e8c02df98f8fb090794f

@sonar-fabrik

sonar-fabrik Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

The requester review request was unavailable. Add the requester through GitHub’s reviewer picker. The PR remains in draft under the ticket’s keep-draft preference.

Generated by Fabrik

@hashicorp-vault-sonar-prod

hashicorp-vault-sonar-prod Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

CLI-1703

Preserve summary-card and section output while exposing reusable stats-local renderers. Add helper boundaries and baseline-verified snapshots.

Co-Authored-By: Fabrik <fabrik@sonarsource.com>
@sonar-fabrik
sonar-fabrik Bot force-pushed the feat/krosovok/CLI-1703-extractStatsHelpers branch from 398fe85 to 6fb2222 Compare November 25, 2026 13:55

@gitar-bot gitar-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gitar has auto-approved this PR (configure)

@gitar-bot gitar-bot Bot added the gitar-approved Added by Gitar label Nov 25, 2026
@gitar-bot

gitar-bot Bot commented Nov 25, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 🟢 Low risk 1 closed / 1 findings

The stats renderer is extracted into shared helpers without changing options, data models, or intended output, limiting impact to presentation.

Extracts the stats rendering helpers (summary card, bar, sparkline, aligned totals layout) into a shared module so other stats files can import them, with text output unchanged. Resolved the type check failure that appeared when merged with the nullable entitlement change in #1393. No issues remain open.

✅ 1 closed
✅ Cross-PR: Type check fails when merged with #1393's nullable entitlement

📄 src/commands/stats/text-report-helpers.ts:87-101 📄 src/commands/stats/text-report-helpers.ts:127-132 📄 src/commands/stats/text-report-helpers.ts:167
Breaks when this PR and #1393 both merge in either order, and the merge keeps this PR's extracted printSummaryCard signature while taking #1393's call site. tsc with strict: true (tsconfig.json:10) then rejects the call.

How

  1. CLI-1702 Build a shared stats view-model #1393 adds StatsViewModel.entitlement: StatsEntitlement | null (src/commands/stats/view-model.ts:22-23) and calls printSummaryCard(summary, since, summary.entitlement, console) (src/commands/stats/text-report.ts:44).
  2. CLI-1702 Build a shared stats view-model #1393 also widens printSummaryCard and buildPlaceholderRows in text-report.ts to StatsEntitlement | null and switches to entitlement?.vortex / entitlement?.sca. This PR deletes exactly those lines from text-report.ts.
  3. This PR's moved copy accepts only StatsEntitlement and dereferences it directly (text-report-helpers.ts:89,96,130,167). The totalRuns === 0 early return does not narrow summary.entitlement, so the call fails type checking.

Fix

Compared 398fe85 with #1393 at cf37746

Verification Rules 3/3 met PRs 1 inspected

Functional validation No results

Rules 3 passed 2 not applicable

✅ Internal artifact registries
✅ Release secrets usage
✅ Repository license compliance

Broader impact PRs 1 inspected
Cross-PR 1 PR inspected 0 open impacts

PR 1393: CLI-1702 Build a shared stats view-model Inspected

Auto-approval Approved

For more verification details, comment gitar display:verbose.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@sonarqubecloud

Copy link
Copy Markdown

@Krosovok
Krosovok self-requested a review November 25, 2026 14:58
@Krosovok
Krosovok marked this pull request as ready for review November 26, 2026 08:29
@Krosovok
Krosovok requested a review from a team as a code owner November 26, 2026 08:29
@Krosovok
Krosovok merged commit f5913de into master Nov 26, 2026
32 checks passed
@Krosovok
Krosovok deleted the feat/krosovok/CLI-1703-extractStatsHelpers branch November 26, 2026 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant