refactor(edge): 偿还 golangci 复杂度豁免并移除 quality-debt 条目 (#1569) - #1611
Conversation
|
Warning Review limit reached
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 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThe 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. ChangesEdge lint debt refactoring
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related issues
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1⚔️ Resolve merge conflicts 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (4)
edge-server/.golangci.ymledge-server/internal/adapters/opencode.goedge-server/internal/adapters/parser_ndjson.goscripts/verify/quality-debt-baseline.json
💤 Files with no reviewable changes (2)
- scripts/verify/quality-debt-baseline.json
- edge-server/.golangci.yml
| 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 |
There was a problem hiding this comment.
🎯 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.
| 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 登记。
89f1be1 to
0a2dea5
Compare
* 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>
提取 opencode BuildCommand 与 parser_ndjson parseLine 的复杂分支为独立辅助函数,使 gocyclo/gocognit 回到阈值内;其余六个文件复杂度已随既有重构降至阈值下,直接移除豁免。同步删除 quality-debt-baseline.json 中对应的 8 条 edge-server 登记。
Closes #1569
Summary by CodeRabbit
Refactor
Chores