Skip to content

linters: unwrap parenthesized call.Fun in trimleftright, httpnoctx, stringreplaceminusone - #74382

Merged
pelikhan merged 1 commit into
mainfrom
sergo/paren-unwrap-callfun-r118-1bb2439dd181e076
Nov 3, 2026
Merged

pelikhan merged 1 commit into
mainfrom
sergo/paren-unwrap-callfun-r118-1bb2439dd181e076

Conversation

@github-actions

@github-actions github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Three linters that CI runs (cgo.yml lines 1674 and 1701, native and wasm) check call.Fun.(*ast.SelectorExpr) without unwrapping parentheses. Because of that, they miss the same call when the function is wrapped in parentheses:

Linter Location Missed form
trimleftright trimleftright.go:59 (strings.TrimRight)(s, "txt")
httpnoctx httpnoctx.go:70 (http.Get)(rawURL)
stringreplaceminusone stringreplaceminusone.go:68,94 (strings.Replace)(s, "o", "0", -1)

This is the per-linter follow-up to the shared-helper fix from the previous Sergo run. That fix (astutil.go:269) is merged. Many linters already use this pattern, including sortslice, lenstringsplit, consolestderr and fileclosenotdeferred.

On the new fixture, gopls/staticcheck QF1004 already reports (strings.Replace)(..., -1). The repo's own stringreplaceminusone linter did not.

Changes

  • Wrap call.Fun with astutil.UnwrapParenExpr at all 4 places listed above.
  • Add one fixture with a parenthesized function per linter. Update stringreplaceminusone.go.golden, because that test uses RunWithSuggestedFixes. The fix text is rebuilt from sel.X, so the parentheses go away.

Validation

  • Serena get_diagnostics_for_file: no diagnostics on all 3 linter source files. The fixture files only show the existing unusedfunc notes plus the expected QF1004 hint.
  • Serena find_referencing_symbols: isStringsReplaceCall has a single caller (run), so nothing else is affected.
  • I could not run go test in this sandbox (the command was denied). A maintainer or CI needs to run:
    go test ./pkg/linters/trimleftright/ ./pkg/linters/httpnoctx/ ./pkg/linters/stringreplaceminusone/

Remaining work

Grep for [^(]\.Fun\.\(\*ast\. still finds about 45 bare call.Fun checks in other linters, for example timesleepnocontext, ctxbackground, sprintfint, execcommandwithoutcontext and timenowsub. These are left for later small PRs.

🤖 Generated with [Claude Code]((claude.com/redacted)

Generated by 🤖 Sergo - Serena Go Expert · claude · routed: opus55 medium · ~120 AIC · ⌖ ~2 AIC · ⊞ 3.8K · ◷

  • expires on Nov 9, 2026, 7:52 PM UTC-08:00

@github-actions github-actions Bot added cookie Issue Monster Loves Cookies! sergo labels Nov 3, 2026
@pelikhan
pelikhan marked this pull request as ready for review November 3, 2026 05:23
Copilot AI adaptive review requested due to automatic review settings November 3, 2026 05:23
@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft.

Design Decision Gate 🏗️

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Design Decision Gate 🏗️ · routed: opus55 xhigh · ~13 AIC · ⌖ ~2 AIC · ⊞ 7.7K · ◷

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Ponytail Reviewer completed successfully!

Ponytail Reviewer

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Ponytail Reviewer · routed: gpt56 max · ~2 AIC · ⌖ ~1 AIC · ⊞ 118 · ◷

Generated by Ponytail Reviewer for #74382

@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor Author

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Test Quality Sentinel · haiku45 · ~10 AIC · ⌖ ~12 AIC · ⊞ 9.4K · ◷

🧪 Test quality analysis by Test Quality Sentinel

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Review: no blocking findings

The parenthesis unwrapping changes are consistent across the three linters, and the added fixtures cover the intended missed forms. No actionable correctness or maintainability issues were identified in the changed lines. Tests were not run as this was a static review.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~2 AIC · ⌖ ~1 AIC · ⊞ 1.7K
Comment /review to run again

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

🟢 Approval recommended

The reviewed linter updates and accompanying fixtures consistently cover parenthesized call forms, with no actionable defects identified.

No open issues 🎉

What changed in this PR

Updates three Go linters to recognize function calls whose function expressions are wrapped in parentheses, ensuring diagnostics and suggested fixes apply consistently to equivalent call forms.

Changes:

  • Unwrap parenthesized call.Fun expressions in trimleftright, httpnoctx, and stringreplaceminusone.
  • Add parenthesized-call fixtures for each linter.
  • Update the stringreplaceminusone suggested-fix golden output.

No actionable defects were identified in the reviewed changes.

File Description
pkg/​linters/​trimleftright/​trimleftright.go Updated as part of this pull request.
pkg/​linters/​trimleftright/​testdata/​src/​trimleftright/​trimleftright.go Updated as part of this pull request.
pkg/​linters/​stringreplaceminusone/​testdata/​src/​stringreplaceminusone/​stringreplaceminusone.go.golden Updated as part of this pull request.
pkg/​linters/​stringreplaceminusone/​testdata/​src/​stringreplaceminusone/​stringreplaceminusone.go Updated as part of this pull request.
pkg/​linters/​stringreplaceminusone/​stringreplaceminusone.go Updated as part of this pull request.
pkg/​linters/​httpnoctx/​testdata/​src/​httpnoctx/​httpnoctx.go Updated as part of this pull request.
pkg/​linters/​httpnoctx/​httpnoctx.go Updated as part of this pull request.

Review effort: Lite (auto)

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Skills-Based Review 🧠

Applied /diagnosing-bugs and /tdd. The triage response was not machine-readable, so skill selection used the fallback bug-fix heuristic.

No actionable issues found in the changed lines. The shared astutil.UnwrapParenExpr helper is applied at each affected call.Fun check, and fixtures cover detection plus the suggested-fix golden output.

Validation: go test ./pkg/linters/trimleftright/ ./pkg/linters/httpnoctx/ ./pkg/linters/stringreplaceminusone/ passed.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: gpt56 max · ~6 AIC · ⌖ ~1 AIC · ⊞ 5.4K
Comment /matt to run again

@pelikhan
pelikhan merged commit 031775f into main Nov 3, 2026
85 checks passed
@pelikhan
pelikhan deleted the sergo/paren-unwrap-callfun-r118-1bb2439dd181e076 branch November 3, 2026 05:36
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

🎉 This pull request is included in a new release.

Release: v1.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cookie Issue Monster Loves Cookies! sergo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants