Skip to content

Refactor 10 SonarCloud cognitive-complexity issues (S3776) - #1425

Closed
Doezer wants to merge 1 commit into
mainfrom
claude/practical-feynman-ppio1i
Closed

Doezer wants to merge 1 commit into
mainfrom
claude/practical-feynman-ppio1i

Conversation

@Doezer

@Doezer Doezer commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

Description

Fixes the 10 most severe open SonarCloud issues on main. All were CRITICAL typescript:S3776 (cognitive complexity above 15). Each fix is a behaviour-preserving extraction of helpers:

File Fix
server/steam-achievements.ts Extracted isWithinMinGap, an error-message constant, and simplified unlock delta
server/steam-playtime.ts Extracted fetchSteamTotals
server/storage.ts Extracted isSyncBlocked from updateGameStatus
shared/backlog-burndown.ts Extracted buildHistory, buildPlayed, countMoves, buildSpans
client/src/components/BacklogBurndown.tsx Extracted describeProjection; shared detectTimeZone
client/src/components/PlayTimeStats.tsx Extracted saveBlob; shared detectTimeZone (new client/src/lib/timezone.ts)
server/downloaders/xmlrpc.ts Extracted getText, parseXmlRpcArray, parseXmlRpcStruct
server/downloaders/transmission.ts Extracted buildRequestHeaders, simplified RPC URL building
server/diagnostics.ts Extracted parseWarnLine, errorMessageOf

Screenshots

The two client files (BacklogBurndown.tsx, PlayTimeStats.tsx) are pure refactors with no markup changes. This was an unattended scheduled run, so no screenshot was captured. Please check the Statistics page before merging.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Refactor (no functional change)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • New and existing unit tests pass locally with my changes (vitest run: 6269 passed; tsc and ESLint clean)

AI-assisted: Claude Sonnet 5.5 (claude-sonnet-5-5), default thinking level.


Generated by Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Steam achievement sync now reports only newly unlocked achievements, avoiding inaccurate unlock counts.
  • Improvements
    • Session exports now clean up temporary download resources automatically.
    • Time zone handling is consistent across backlog and playtime views.

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-23T12:21:56.655451Z
We couldn’t complete this review. Comment @codex review to try again.
c3cbcd5 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@gitar-bot

gitar-bot Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor
CI failed: The 'Milestone is set' CI check failed because the pull request has no milestone assigned, a configuration issue. The analyzer attributes it to missing PR metadata rather than the S3776 cognitive-complexity refactor, with high confidence.

Overview

The 'Milestone is set' CI check failed because the pull request has no milestone assigned, a configuration issue. The analyzer attributes it to missing PR metadata rather than the S3776 cognitive-complexity refactor, with high confidence.

Failures

Milestone check failed: PR has no milestone assigned (unrelated to change)

  • Type: configuration
  • Affected jobs: 137689039850
  • Related to change: no
  • Confidence: high
  • Root cause: The job received an empty MILESTONE value and intentionally exited with code 1, reporting “Milestone missing.” The PR changes refactor SonarCloud cognitive-complexity issues; no supplied evidence connects those code changes to the missing PR metadata.
  • Suggested fix: Assign the current release milestone to the pull request so the check can rerun.

Summary

  • Change-related failures: 0
  • Infrastructure/flaky failures: 0
  • Recommended action: Assign the current release milestone to the pull request so the check can rerun.
Code Review ✅ Approved 🟢 Low risk

The helper extractions preserve the supplied logic across server and client code, limiting impact to internal structure with no meaningful behavior or interface change.

Refactors 10 SonarCloud S3776 cognitive-complexity hotspots across server, shared, and client code by extracting behaviour-preserving helpers such as isSyncBlocked, fetchSteamTotals, and parseXmlRpcArray. No issues found.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Approved

For more verification details, comment gitar display:verbose.

Tip

Comment Gitar fix CI or enable auto-apply: gitar auto-apply:on

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 👍 / 👎 | Powered by Gitar — free for open source

@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The changes extract helpers for client timezone detection, session downloads, backlog calculations, diagnostic parsing, downloader requests, Steam synchronization, and game status checks. The summaries report that the existing conditions and outcomes are retained.

Changes: Client statistics and backlog

Layer / File(s) Summary
Timezone detection in client components
client/src/lib/timezone.ts, client/src/components/BacklogBurndown.tsx, client/src/components/PlayTimeStats.tsx
Added detectTimeZone and used it in both components in place of their inline timezone lookups.
Backlog calculations and projection
shared/backlog-burndown.ts, client/src/components/BacklogBurndown.tsx
Extracted helpers for status history, played sessions, move counts, and time spans. Projection-message selection now uses describeProjection.
Session blob download
client/src/components/PlayTimeStats.tsx
Added saveBlob for session downloads, including link removal and delayed object URL revocation. The export filename remains format-specific.

Diagnostic error parsing

Layer / File(s) Summary
Parse diagnostic warning lines
server/diagnostics.ts
Added error-message and warning-line parsing helpers, and updated summarizeErrors to skip lines the helper rejects. The HostKind members are unchanged.

Downloader request and XML-RPC helpers

Layer / File(s) Summary
Build Transmission RPC requests
server/downloaders/transmission.ts
Extracted request-header construction and used it in makeRequest. The RPC body and existing retry and error handling remain unchanged.
Parse XML-RPC arrays and structs
server/downloaders/xmlrpc.ts
Moved text unwrapping to file scope and extracted array and struct conversion helpers. The parsing behavior is retained.

Steam synchronization

Layer / File(s) Summary
Apply achievement sync rules
server/steam-achievements.ts
Extracted the minimum-gap check and shared failure message. Unlock reporting uses the positive difference from the prior count.
Fetch Steam playtime totals
server/steam-playtime.ts
Extracted Steam total retrieval and the existing upstream-error handling from planSteamImport.

Game status synchronization guard

Layer / File(s) Summary
Centralize status sync blocking
server/storage.ts
Added isSyncBlocked and replaced the inline guards in MemStorage.updateGameStatus. The downloadTypes union members are unchanged.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor

Possibly related PRs

  • Doezer/Questarr#1415: Refactors overlapping functions in Steam imports, storage, backlog burndown, play-time statistics, XML-RPC parsing, Transmission requests, and diagnostics.

Suggested reviewers: claude, openhands-agent

Merge Risk: Minimal · up to c3cbc

This PR refactors helpers to reduce code complexity and is intended to preserve behavior. No concrete regression was found. Set the pull request milestone so the process check passes.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names a refactor that reduces cognitive complexity, which matches the changeset. The changes extract helpers in server, shared, and client files to address SonarCloud S3776 findings, so the …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names a refactor that reduces cognitive complexity, which matches the changeset. The changes extract helpers in server, shared, and client files to address SonarCloud S3776 findings, so the title describes the primary change from the developer's perspective. The phrase 'Refactor 10 SonarCloud cognitive-complexity issues' is specific and concise, and it conveys the intent of the changes without listing files.

Finishing Touches

Fix failing CI checks

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5b27224f-292f-44c4-bde1-5552e7d32533
Commits

Reviewing files that changed from the base of the PR and between 64e7765 and c3cbcd5.

Files selected for processing: 10

  • client/src/components/BacklogBurndown.tsx
  • client/src/components/PlayTimeStats.tsx
  • client/src/lib/timezone.ts
  • server/diagnostics.ts
  • server/downloaders/transmission.ts
  • server/downloaders/xmlrpc.ts
  • server/steam-achievements.ts
  • server/steam-playtime.ts
  • server/storage.ts
  • shared/backlog-burndown.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

Doezer commented Nov 23, 2026

Copy link
Copy Markdown
Owner Author

The "Milestone is set" check fails because this PR has no milestone. The diff can't fix that, and the GitHub tools available to this session can't set one, so a maintainer needs to assign it. Codex review also failed because the Codex usage limit was reached, so no review ran. The remaining checks are still running.


Generated by Claude Code

@gitar-bot gitar-bot Bot left a comment

Copy link
Copy Markdown
Contributor

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)

@Doezer

Doezer commented Nov 23, 2026

Copy link
Copy Markdown
Owner Author

wshm · Automated triage by AI

📊 Automated PR Analysis

♻️ Type refactor
🟡 Risk medium

Summary

This PR refactors the 10 most severe open SonarCloud cognitive-complexity (S3776) issues across several server and client files by extracting helper functions, without changing behavior. Changes span steam-achievements, steam-playtime, storage, backlog-burndown, BacklogBurndown/PlayTimeStats components, xmlrpc, transmission, and diagnostics modules, including a new shared timezone utility.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Analyzed automatically by wshm · This is an automated analysis, not a human review.

@codecov

codecov Bot commented Nov 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.41985% with 6 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
server/storage.ts 20.00% 4 Missing ⚠️
client/src/lib/timezone.ts 75.00% 1 Missing ⚠️
server/diagnostics.ts 95.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@Doezer Doezer added this to the 1.7.0 milestone Nov 26, 2026

Doezer commented Nov 26, 2026

Copy link
Copy Markdown
Owner Author

Closing as superseded by #1446. This branch conflicts with main and overlaps #1415/#1438. #1446 is clean against main and covers the issues Sonar still reports there. Not carried over: the client changes (BacklogBurndown.tsx, PlayTimeStats.tsx, lib/timezone.ts), which need UI screenshots, plus steam-achievements.ts and transmission.ts. Those can come back as a separate PR with visual evidence. Reopen if you'd rather land this one.


Generated by Claude Code

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.

2 participants