Skip to content

refactor(edge): 偿还 golangci 复杂度豁免并移除 quality-debt 条目 (#1569) - #1611

Merged
DeliciousBuding merged 2 commits into
masterfrom
refactor/edge-complexity
Aug 4, 2026
Merged

refactor(edge): 偿还 golangci 复杂度豁免并移除 quality-debt 条目 (#1569)#1611
DeliciousBuding merged 2 commits into
masterfrom
refactor/edge-complexity

Conversation

@DeliciousBuding

@DeliciousBuding DeliciousBuding commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

提取 opencode BuildCommand 与 parser_ndjson parseLine 的复杂分支为独立辅助函数,使 gocyclo/gocognit 回到阈值内;其余六个文件复杂度已随既有重构降至阈值下,直接移除豁免。同步删除 quality-debt-baseline.json 中对应的 8 条 edge-server 登记。

Closes #1569

Summary by CodeRabbit

  • Refactor

    • Improved command construction and message parsing for clearer, more maintainable processing.
    • Preserved existing handling for prompts, permissions, attachments, progress updates, authentication, rate limits, and cancellations.
  • Chores

    • Strengthened code-quality checks across additional server components by removing outdated lint exclusions.
    • Updated quality baselines to reflect the expanded validation coverage.

Copilot AI lite review requested due to automatic review settings August 4, 2026 15:32

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@DeliciousBuding, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 47 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 25046c02-f050-4019-9271-104418ec2b51

📥 Commits

Reviewing files that changed from the base of the PR and between 89f1be1 and d3a36ca.

📒 Files selected for processing (5)
  • edge-server/.golangci.yml
  • edge-server/internal/adapters/opencode.go
  • edge-server/internal/adapters/parser_ndjson.go
  • scripts/verify/quality-debt-baseline.json
  • scripts/verify/tests/verify-quality-debt-ratchet.Tests.ps1
📝 Walkthrough

Walkthrough

The change refactors OpenCode command construction and NDJSON parsing into helpers. It also removes related Edge server lint exclusions from the linter configuration and quality-debt baseline.

Changes

Edge lint debt refactoring

Layer / File(s) Summary
Adapter parsing and command refactors
edge-server/internal/adapters/opencode.go, edge-server/internal/adapters/parser_ndjson.go
OpenCode argument, prompt, and environment construction now use helpers. NDJSON control requests, system messages, attachments, and event types now use dedicated handlers.
Lint exclusion baseline cleanup
edge-server/.golangci.yml, scripts/verify/quality-debt-baseline.json
Removed file-specific Edge server lint exclusions and their baseline records.

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

Possibly related issues

Possibly related PRs

Suggested reviewers: copilot

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the refactoring, removal of golangci complexity exemptions, and deletion of quality-debt entries.
Linked Issues check ✅ Passed The changes refactor parser_ndjson and opencode, remove the listed golangci exemptions, and update the quality-debt baseline.
Out of Scope Changes check ✅ Passed All changed files support the linked issue objectives for complexity refactoring, exemption removal, and baseline maintenance.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches 💡 1
⚔️ Resolve merge conflicts 💡
  • Resolve merge conflict in branch refactor/edge-complexity
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/edge-complexity

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

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@edge-server/internal/adapters/opencode.go`:
- Around line 112-124: Normalize ctx.WorkDir before the
appendOpenCodeModelArgs/appendOpenCodeRunArgs/appendOpenCodeOverrideArgs flow
builds the --dir argument, then reuse that normalized value for the returned
process workDir. Ensure whitespace-only values do not add an invalid --dir
argument while preserving the existing empty-workDir behavior.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: e81b8ed8-3b46-401c-9e8d-63fa9fbc081f

📥 Commits

Reviewing files that changed from the base of the PR and between a51aade and 89f1be1.

📒 Files selected for processing (4)
  • edge-server/.golangci.yml
  • edge-server/internal/adapters/opencode.go
  • edge-server/internal/adapters/parser_ndjson.go
  • scripts/verify/quality-debt-baseline.json
💤 Files with no reviewable changes (2)
  • scripts/verify/quality-debt-baseline.json
  • edge-server/.golangci.yml

Comment on lines +112 to +124
args = appendOpenCodeModelArgs(args, ctx)
args = appendOpenCodeRunArgs(args, ctx)
args = appendOpenCodeOverrideArgs(args, ctx)

prompt = buildOpenCodePrompt(ctx, prompt)
args = append(args, prompt)

// Empty workDir is rejected at REST/MCP gates (#854). Do not fall back to
// UserHomeDir/DefaultWorkDir; keep empty and let the process CWD stay unset
// if a bypass path reaches BuildCommand.
workDir := strings.TrimSpace(ctx.WorkDir)

return a.binaryPath, args, buildOpenCodeEnv(ctx), workDir

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Normalize ctx.WorkDir before building --dir.

Line 122 trims the process working directory after Line 114 adds the raw value to --dir. A value such as " /repo " gives the process "/repo" but gives OpenCode " /repo ". A whitespace-only value also adds an invalid --dir argument.

Proposed fix
 func (a *OpenCodeAdapter) BuildCommand(ctx RunProcessContext) (string, []string, []string, string) {
+	// Empty workDir is rejected at REST/MCP gates (`#854`). Do not fall back to
+	// UserHomeDir/DefaultWorkDir; keep empty and let the process CWD stay unset.
+	workDir := strings.TrimSpace(ctx.WorkDir)
+	ctx.WorkDir = workDir
+
 	prompt := ctx.Prompt
 	if prompt == "" {
 		prompt = "Continue."
 	}
@@
-	// Empty workDir is rejected at REST/MCP gates (`#854`). Do not fall back to
-	// UserHomeDir/DefaultWorkDir; keep empty and let the process CWD stay unset
-	// if a bypass path reaches BuildCommand.
-	workDir := strings.TrimSpace(ctx.WorkDir)
-
 	return a.binaryPath, args, buildOpenCodeEnv(ctx), workDir
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
args = appendOpenCodeModelArgs(args, ctx)
args = appendOpenCodeRunArgs(args, ctx)
args = appendOpenCodeOverrideArgs(args, ctx)
prompt = buildOpenCodePrompt(ctx, prompt)
args = append(args, prompt)
// Empty workDir is rejected at REST/MCP gates (#854). Do not fall back to
// UserHomeDir/DefaultWorkDir; keep empty and let the process CWD stay unset
// if a bypass path reaches BuildCommand.
workDir := strings.TrimSpace(ctx.WorkDir)
return a.binaryPath, args, buildOpenCodeEnv(ctx), workDir
func (a *OpenCodeAdapter) BuildCommand(ctx RunProcessContext) (string, []string, []string, string) {
// Empty workDir is rejected at REST/MCP gates (`#854`). Do not fall back to
// UserHomeDir/DefaultWorkDir; keep empty and let the process CWD stay unset.
workDir := strings.TrimSpace(ctx.WorkDir)
ctx.WorkDir = workDir
args = appendOpenCodeModelArgs(args, ctx)
args = appendOpenCodeRunArgs(args, ctx)
args = appendOpenCodeOverrideArgs(args, ctx)
prompt = buildOpenCodePrompt(ctx, prompt)
args = append(args, prompt)
return a.binaryPath, args, buildOpenCodeEnv(ctx), workDir
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@edge-server/internal/adapters/opencode.go` around lines 112 - 124, Normalize
ctx.WorkDir before the
appendOpenCodeModelArgs/appendOpenCodeRunArgs/appendOpenCodeOverrideArgs flow
builds the --dir argument, then reuse that normalized value for the returned
process workDir. Ensure whitespace-only values do not add an invalid --dir
argument while preserving the existing empty-workDir behavior.

提取 opencode BuildCommand 与 parser_ndjson parseLine 的复杂分支为
独立辅助函数,使 gocyclo/gocognit 均回到阈值内;其余六个文件的
复杂度已随既有重构降至阈值下,直接移除豁免。同步删除
quality-debt-baseline.json 中对应的 8 条 edge-server 登记。
@DeliciousBuding
DeliciousBuding force-pushed the refactor/edge-complexity branch from 89f1be1 to 0a2dea5 Compare August 4, 2026 15:38
@DeliciousBuding
DeliciousBuding merged commit f1b6323 into master Aug 4, 2026
22 checks passed
@DeliciousBuding
DeliciousBuding deleted the refactor/edge-complexity branch August 4, 2026 15:58
DeliciousBuding added a commit that referenced this pull request Aug 4, 2026
DeliciousBuding added a commit that referenced this pull request Aug 11, 2026
* refactor(edge): 偿还 golangci 复杂度豁免并移除 quality-debt 条目 (#1569)

提取 opencode BuildCommand 与 parser_ndjson parseLine 的复杂分支为
独立辅助函数,使 gocyclo/gocognit 均回到阈值内;其余六个文件的
复杂度已随既有重构降至阈值下,直接移除豁免。同步删除
quality-debt-baseline.json 中对应的 8 条 edge-server 登记。

* test(verify): quality-debt 负测试改用合成排除条目,适配豁免清零后的空 baseline (#1569)

---------

Co-authored-by: Codex <codex@vectorcontrol.tech>
DeliciousBuding added a commit that referenced this pull request Aug 11, 2026
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.

[P2] 偿还 Edge golangci 复杂度豁免:parser/opencode/codex/process_executor 等热点

2 participants