Skip to content

Reduce cognitive complexity in 10 SonarCloud critical issues - #1434

Merged
Doezer merged 1 commit into
mainfrom
claude/practical-feynman-4zsy2w
Nov 24, 2026
Merged

Doezer merged 1 commit into
mainfrom
claude/practical-feynman-4zsy2w

Conversation

@Doezer

@Doezer Doezer commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

Description

Fixes 10 of the 115 open Critical SonarCloud issues on main (all typescript:S3776, cognitive complexity above 15; there are no Blockers). I picked the ten with the smallest overshoot (16–17 against the limit of 15) in server/shared code. Each fix extracts helpers and does not change behavior.

File Fix
shared/quests.ts questProgress countTouched helper replaces two duplicated loops
server/storage.ts updateGameStatus isSyncBlocked guard
server/game-version.ts recordVersionFromCompletedDownload writeReleaseVersion compare-and-set helper
server/game-version.ts recordVersionFromInstallFolder shouldWriteInstallVersion helper
server/library-scanner.ts matchUnmatchedFolder upsertMatchedGame helper
server/library-scanner.ts processCandidate assignToExistingGame helper
server/backup/restore.ts parseManifest assertManifestComplete helper
server/downloaders/transmission.ts makeRequest retryWithSessionId method
server/rss.ts fetchFeed backfillLinks method
server/steam-playtime.ts planSteamImport fetchSteamTotals and groupBy helpers

105 Critical issues remain, mostly larger refactors (e.g. ImportManager.ts at complexity 55).

Screenshots

Backend-only change, no UI touched.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactor (no behavior change)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • New and existing unit tests pass locally with my changes (6359 passed), tsc and ESLint clean
  • If AI is used to write the code: written by Claude Sonnet 5.5 (claude-sonnet-5-5), default thinking level.

Generated by Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Backup restores now report which required file is missing when a manifest is incomplete.
    • Transmission requests retry correctly when the server requires an updated session ID.
    • Library scans better preserve curated game statuses and existing library paths while recording newly matched files.
    • Existing feed items can now have missing links filled in when link extraction is enabled.
    • Sync updates are blocked for games that are downloading or have protected statuses.
  • Improvements
    • Game version updates are more resilient to concurrent changes.

Extract helpers in quests, storage, game-version, library-scanner, restore,
transmission, rss and steam-playtime without changing behavior.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RP6NCUc3nNkDKKQpeeN4DB
@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-24T12:21:34.323837Z
We couldn’t complete this review. Comment @codex review to try again.
80fa726 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.

Doezer commented Nov 24, 2026

Copy link
Copy Markdown
Owner Author

The "Milestone is set" check fails because this PR has no milestone. It is unrelated to the code change. I can't set one from this session and the right release milestone is a maintainer's call, so a maintainer needs to assign it.

The Codex review also failed because the Codex usage limit was reached, so it did not review the change.


Generated by Claude Code

@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The changes extract and reuse helpers across backup validation, Transmission retries, game-version recording, library scanning, RSS link backfill, Steam import planning, storage status updates, and quest progress counting.

Changes: Backup manifest validation

Layer / File(s) Summary
Manifest completeness validation
server/backup/restore.ts
assertManifestComplete checks for required database files in Postgres and SQLite manifests. parseManifest calls the helper. The required-file checks are no longer inline.

Transmission session retry

Layer / File(s) Summary
Session-ID retry handling
server/downloaders/transmission.ts
makeRequest delegates a 409 response with a session ID to retryWithSessionId. The helper repeats the POST and handles successful and error responses.

Game version recording

Layer / File(s) Summary
Version write checks and recording
server/game-version.ts
writeReleaseVersion handles up to three compare-and-set attempts. shouldWriteInstallVersion checks install-version eligibility. The recording functions use these helpers and the VersionStore alias.

Library scanning

Layer / File(s) Summary
Matched-game updates during scanning
server/library-scanner.ts
upsertMatchedGame handles game lookup, creation, status, and library path updates. assignToExistingGame handles file assignment and matched counts in existing-game branches.

RSS link backfill

Layer / File(s) Summary
Backfill links for existing items
server/rss.ts
backfillLinks checks feed identity, extraction settings, and existing links before updating an item. fetchFeed delegates its existing-item path to the helper.

Steam import planning

Layer / File(s) Summary
Steam totals and session grouping
server/steam-playtime.ts
fetchSteamTotals handles the upstream request and sanitized errors. groupBy replaces the inline session-grouping loop in planSteamImport.

Storage status updates

Layer / File(s) Summary
Sync status guard
server/storage.ts
isSyncBlocked centralizes the existing status checks used by MemStorage.updateGameStatus.

Quest progress counting

Layer / File(s) Summary
Count touched games for quests
shared/quests.ts
countTouched counts known games that satisfy a predicate. backlog_slayer and retro_explorer use it with their respective predicates.

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

Change: Refactor

Possibly related PRs

  • Doezer/Questarr#1338: Adds the backup and restore feature whose manifest validation is now handled by a helper.
  • Doezer/Questarr#1415: Extracts helpers in overlapping areas, including Steam imports, storage, and Transmission requests.

Suggested labels: refactor, code-quality

Suggested reviewers: claude, gitar-bot

Merge Risk: Minimal · up to 80fa7

This refactor extracts helpers without intended behavior changes, and no concrete regression was found. The failing milestone check only needs a milestone set on the pull request.

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 says the PR reduces cognitive complexity in 10 SonarCloud critical issues. The raw summary and objectives match this. The changes extract helpers across quests, storage, game versioning, lib…
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 says the PR reduces cognitive complexity in 10 SonarCloud critical issues. The raw summary and objectives match this. The changes extract helpers across quests, storage, game versioning, library scanning, backup restore, Transmission, RSS, and Steam playtime, with no behavior change. The title names the main change and states the goal, so it passes.

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: e8ce6638-4f10-4e04-abce-378d86376e09
Commits

Reviewing files that changed from the base of the PR and between 5b4eb9d and 80fa726.

Files selected for processing: 8

  • server/backup/restore.ts
  • server/downloaders/transmission.ts
  • server/game-version.ts
  • server/library-scanner.ts
  • server/rss.ts
  • server/steam-playtime.ts
  • server/storage.ts
  • shared/quests.ts

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

@gitar-bot

gitar-bot Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor
CI failed: The 'Milestone is set' CI job failed because the pull request has no milestone assigned, a PR metadata requirement the analyzer judged unrelated to the refactoring change. Assigning a milestone and rerunning should resolve it.

Overview

The 'Milestone is set' CI job failed because the pull request has no milestone assigned, a PR metadata requirement the analyzer judged unrelated to the refactoring change. Assigning a milestone and rerunning should resolve it.

Failures

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

  • Type: configuration
  • Affected jobs: 138440395506
  • Related to change: no
  • Confidence: high
  • Root cause: The workflow received an empty MILESTONE value and exited with code 1. This is a pull-request metadata requirement; the supplied PR change evidence describes code refactoring and does not connect it to the missing milestone.
  • Suggested fix: Assign the appropriate release milestone to the pull request, then rerun the check.

Summary

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

The changes extract existing server and shared-code logic into helpers, with the supplied implementations preserving behavior and no meaningful impact.

Refactors cognitive complexity in 10 SonarCloud critical issues across shared, server, and downloader code by extracting helpers such as countTouched, isSyncBlocked, and retryWithSessionId, with no behavior change. 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

@sonarqubecloud

Copy link
Copy Markdown

@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 24, 2026

Copy link
Copy Markdown
Owner Author

wshm · Automated triage by AI

📊 Automated PR Analysis

♻️ Type refactor
🟢 Risk low

Summary

This PR refactors 10 server/shared TypeScript functions to reduce cognitive complexity, addressing 10 of 115 open SonarCloud Critical issues (typescript:S3776) by extracting helper functions, without changing behavior. The targeted files include game-version.ts, library-scanner.ts, transmission.ts, rss.ts, steam-playtime.ts, and others.

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 24, 2026

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Patch % Lines
server/library-scanner.ts 72.22% 5 Missing ⚠️
server/storage.ts 20.00% 4 Missing ⚠️
server/backup/restore.ts 77.77% 2 Missing ⚠️
server/game-version.ts 96.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@Doezer Doezer added this to the 1.7.0 milestone Nov 24, 2026
@Doezer
Doezer merged commit 276d455 into main Nov 24, 2026
19 of 20 checks passed
@Doezer
Doezer deleted the claude/practical-feynman-4zsy2w branch November 24, 2026 21:59
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