Skip to content

Refactor high-complexity functions flagged by SonarCloud - #1438

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

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

Conversation

@Doezer

@Doezer Doezer commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fixes 5 of the 10 most severe open SonarCloud issues on main (all CRITICAL, typescript:S3776 cognitive complexity), by extracting helpers with no behaviour change:

  • shared/backlog-burndown.ts (lines 87 and 152): computeBacklogBurndown split into history, span and projection helpers.
  • server/quest-service.ts: syncQuests loop body moved into settleQuest.
  • server/downloaders/xmlrpc.ts: parseXmlRpcValue split into scalar, array and struct parsers.
  • server/diagnostics.ts: summarizeErrors split into parseLogLine and errorFieldMessage.

Not fixed (remaining from the top 10)

  • server/services/ImportStrategies.ts lines 346, 443, 742: larger refactors of file-transfer logic, left for a dedicated PR.
  • client/src/components/BacklogBurndown.tsx and PlayTimeStats.tsx: UI files, which need visual evidence under the repo rules.

Testing

  • npx tsc --noEmit clean, ESLint and Prettier clean.
  • npx vitest run server shared: 5113 passed, 10 skipped.

No client/src changes.


Generated by Claude Code

Summary by CodeRabbit

  • Refactor
    • Restructured internal handling of diagnostics, XML-RPC responses, quest updates, and backlog reports. Existing behavior is preserved, with no changes to user-facing functionality.

Split computeBacklogBurndown, syncQuests, parseXmlRpcValue and summarizeErrors
into smaller helpers to bring cognitive complexity under the limit. No
behaviour change.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RP6NCSAVaLrdRATuEuUw8y
@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-25T12:22:22.965877Z
We couldn’t complete this review. Comment @codex review to try again.
60d1f69 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 25, 2026

Copy link
Copy Markdown
Owner Author

The "Milestone is set" check fails because this PR has no milestone. That's a repo-management choice I can't make, so a maintainer needs to assign one; the check should then pass on re-run. No code change is needed for it. The Codex review failure is a usage-limit error on its side, not a finding in this PR.


Generated by Claude Code

@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The changes extract parsing, settlement, and backlog calculations into helpers. The summaries state that existing parsing and burndown behavior is retained, while quest settlement now runs through settleQuest.

Changes: Diagnostics error summaries

Layer / File(s) Summary
Error-line parsing and extraction
server/diagnostics.ts
Local helpers parse log lines and extract error messages. summarizeErrors continues to skip invalid entries and entries without a numeric level of at least 40.

XML-RPC value parsing

Layer / File(s) Summary
Scalar, array, and struct parsing
server/downloaders/xmlrpc.ts
parseXmlRpcValue delegates to helpers for scalar, array, and struct values. Unrecognized scalar tags use a sentinel so parsing can continue to arrays, structs, or the existing fallback.

Quest settlement

Layer / File(s) Summary
Quest settlement and sync integration
server/quest-service.ts
settleQuest handles active-quest progress and status updates, update failures, and completion notifications. syncQuests appends the returned quest.

Backlog burndown

Layer / File(s) Summary
History construction and lookup
shared/backlog-burndown.ts
Helpers build status and play histories, provide day lookups, and support backlog calculations.
Burndown buckets and clearance projection
shared/backlog-burndown.ts
Helpers generate time spans, count transitions, and calculate the clearance date used in the result.

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

Change: Refactor

Possibly related PRs

  • Doezer/Questarr#1415: It refactors computeBacklogBurndown, parseXmlRpcValue, and summarizeErrors, which are also changed here.

Suggested reviewers: claude, openhands-agent, gitar-bot

Merge Risk: Minimal · up to 60d1f

This refactor extracts helpers without intended behavior change, and no concrete defects were found. Merging needs only a milestone assigned 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 names the main change: refactoring four high-complexity functions flagged by SonarCloud. The raw summary confirms the changes split computeBacklogBurndown, syncQuests, parseXmlRpcValue, and …
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 the main change: refactoring four high-complexity functions flagged by SonarCloud. The raw summary confirms the changes split computeBacklogBurndown, syncQuests, parseXmlRpcValue, and summarizeErrors into helpers without changing behavior. The title is specific and matches the changeset.

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: 22f18f80-80bd-4fc0-a19e-36d979100fb1
Commits

Reviewing files that changed from the base of the PR and between 6314e34 and 60d1f69.

Files selected for processing: 4

  • server/diagnostics.ts
  • server/downloaders/xmlrpc.ts
  • server/quest-service.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.

@sonarqubecloud

Copy link
Copy Markdown

@gitar-bot

gitar-bot Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor
CI failed: The 'Milestone is set' CI job failed because the pull request has no milestone assigned, a configuration issue. The analyzer marked this as unrelated to the refactor changes, so no change-related failures were identified.

Overview

The 'Milestone is set' CI job failed because the pull request has no milestone assigned, a configuration issue. The analyzer marked this as unrelated to the refactor changes, so no change-related failures were identified.

Failures

Milestone is set job fails: PR has no milestone assigned (unrelated to change)

  • Type: configuration
  • Affected jobs: 139201495715
  • Related to change: no
  • Confidence: high
  • Root cause: The job found MILESTONE empty and intentionally exited with code 1. The PR metadata shows no milestone, while the supplied code changes are function refactors unrelated to this metadata check; this failure is not caused by the PR changes.
  • Suggested fix: Assign the pull request an appropriate release milestone and rerun the check.

Summary

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

Helper extraction in four server/shared modules preserves the shown calculations, parsing, and quest updates, limiting impact to internal structure without interface changes.

Refactors high-complexity functions flagged by SonarCloud (S3776) in shared/backlog-burndown.ts, server/quest-service.ts, server/downloaders/xmlrpc.ts, and server/diagnostics.ts by extracting helpers with no intended behaviour 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

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

Copy link
Copy Markdown
Owner Author

wshm · Automated triage by AI

📊 Automated PR Analysis

♻️ Type refactor
🟡 Risk medium

Summary

Refactors five SonarCloud-flagged high-complexity functions across diagnostics, xmlrpc parsing, quest-service, and backlog-burndown modules by extracting smaller helper functions, with no intended behavior change. The PR explicitly defers larger refactors of ImportStrategies.ts and UI component files to future PRs.

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

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Patch % Lines
server/quest-service.ts 90.47% 2 Missing ⚠️
server/diagnostics.ts 92.30% 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 #1446 (clean against main) covers the same functions here (computeBacklogBurndown, syncQuests, parseXmlRpcValue). The diagnostics.ts part no longer matches an open Sonar issue on main. 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