Repository navigation
Recognize parenthesized callees in timesleepnocontext, ctxbackground, execcommandwithoutcontext - #74737
Conversation
|
✅ PR Code Quality Reviewer completed the code quality review.
|
|
✅ Test Quality Sentinel completed test quality analysis. Test Quality SentinelOutcome: 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.
|
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅
|
|
✅ Ponytail Reviewer completed successfully! Ponytail ReviewerOutcome: 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.
|
|
✅ 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: 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.
|
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the changes extending context-cancellation checks to parenthesized calls.
No open issues 🎉
What changed in this PR
This PR closes a detection gap in three gh-aw linters so parenthesized calls receive the same context-cancellation checks as ordinary calls.
Changes:
- Unwrap parenthesized callees in
timesleepnocontext,ctxbackground, andexeccommandwithoutcontext. - Replace duplicated package-identity checks with
astutil.IsPkgSelector. - Add regression fixtures and expected suggested-fix outputs.
| File | Description |
|---|---|
pkg/linters/timesleepnocontext/timesleepnocontext.go |
Recognizes parenthesized time.Sleep calls using shared helpers. |
pkg/linters/timesleepnocontext/testdata/src/timesleepnocontext/timesleepnocontext.go |
Adds a parenthesized sleep regression case. |
pkg/linters/execcommandwithoutcontext/testdata/src/execcommandwithoutcontext/execcommandwithoutcontext.go.golden |
Records the expected parenthesized CommandContext fix. |
pkg/linters/execcommandwithoutcontext/testdata/src/execcommandwithoutcontext/execcommandwithoutcontext.go |
Adds a parenthesized command regression case. |
pkg/linters/execcommandwithoutcontext/execcommandwithoutcontext.go |
Recognizes parenthesized exec.Command calls using shared helpers. |
pkg/linters/ctxbackground/testdata/src/ctxbackground/ctxbackground.go.golden |
Records replacement of the parenthesized call with ctx. |
pkg/linters/ctxbackground/testdata/src/ctxbackground/ctxbackground.go |
Adds a parenthesized background-context regression case. |
pkg/linters/ctxbackground/ctxbackground.go |
Recognizes parenthesized context.Background calls and documents support. |
Review effort: Balanced (auto)
There was a problem hiding this comment.
Review summary
No actionable correctness, performance, or maintainability issues found in the changed lines. The specialist pass was unavailable/invalid, so this verdict is based on the independent source review.
🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~2 AIC · ⌖ ~1 AIC · ⊞ 1.6K
Comment /review to run again
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /tdd and /diagnosing-bugs (regression-test check) and /codebase-design (shared helper reuse). No actionable issues found; approving.
📋 Key Themes & Highlights
Verification
- ✅
go testpasses fortimesleepnocontext,ctxbackground, andexeccommandwithoutcontext;gofmtandgo vetare clean. - ✅ Regression check: with the three source hunks reverted, the new parenthesized-callee fixtures fail (
wantvs.fixedmismatch), so they guard the change. - ✅
IsPkgSelectorandUnwrapParenExprexist inpkg/linters/internal/astutiland match the removed inline logic. The package-identity check still goes throughtypes.PkgName, andgo/typesis no longer needed in these files. - ✅ No parenthesized
time.Sleep,context.Background, orexec.Commandcallees in non-testdata code, so the stricter matching adds no new CI findings (the PR body's claim holds).
Notes (non-blocking)
- The
pkg/linters/README.mddescriptions for these three linters do not mention parenthesized callees. Consider a short note there so the behaviour is discoverable.
@pelikhan the three linters now recognise parenthesized callees and the shared helper is used consistently. Thanks for the clear PR description and evidence.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~3 AIC · ⌖ ~1 AIC · ⊞ 5.4K
Comment /matt to run again
|
🎉 This pull request is included in a new release. Release: |
Summary
Three linters that CI runs on this repo (
.github/workflows/cgo.yml:1674and:1701) type-assertcall.Fundirectly. Because of that, they don't flag a call whose function is wrapped in parentheses:timesleepnocontext(time.Sleep)(d)inside a function that takesctxctxbackground(context.Background)()inside a function that takesctxexeccommandwithoutcontext(exec.Command)(name)inside a function that takesctxThis PR wraps
call.Funinastutil.UnwrapParenExpr, the same fix used in the earliertrimleftright/httpnoctx/stringreplaceminusonebatch. It also replaces each linter's copy of the 12-line "is this selector on package X" check withastutil.IsPkgSelector, which more than 20 linters already use. Net change: −9 lines, and thego/typesimport is gone from all three files.Evidence
.Fun.(*ast.inpkg/(non-test files) foundtimesleepnocontext.go:83,ctxbackground.go:84andexeccommandwithoutcontext.go:111.find_referencing_symbolsonastutil.IsPkgSelectorlists 20+ callers that use the same package-identity check these three copied by hand.pkg/currently uses a parenthesizedtime.Sleep,context.Backgroundorexec.Commandcallee, so the stricter check adds no new CI findings.Changes
pkg/linters/timesleepnocontext/timesleepnocontext.go:isTimeSleepCallnow unwraps parentheses and usesIsPkgSelector.pkg/linters/ctxbackground/ctxbackground.go:isContextBackgroundCallgets the same change, plus a doc comment.pkg/linters/execcommandwithoutcontext/execcommandwithoutcontext.go:execCommandSelectorgets the same change. The suggested fix still editssel.Seland inserts aftercall.Lparen, so(exec.Command)(name)becomes(exec.CommandContext)(ctx, name).testdata. Added the matching.goldenfixes for the two linters that useRunWithSuggestedFixes(ctxbackgroundproduces_ = ctx;execcommandwithoutcontextproduces(exec.CommandContext)(ctx, name)).Validation
get_diagnostics_for_file(gopls) reports 0 diagnostics on all three changed source files and on theexeccommandwithoutcontextfixture. That rules out an unusedgo/typesimport or type errors.go test,gofmtandmake fmtwere denied by the agent's permission layer. CI should rungo test ./pkg/linters/timesleepnocontext/ ./pkg/linters/ctxbackground/ ./pkg/linters/execcommandwithoutcontext/. The new fixtures add onewanteach, and the two new golden entries need to match.Remaining bare
call.Funtype assertions (follow-up candidates)sprintfint.go:52(has a golden file),timenowsub.go:42/99,errstringmatch.go:82/102,timeafterleak.go:70,closeerrorunchecked.go:116,httprespbodyclose.go:261,hardcodedfilepath.go:135, and about 30 more. These can go in small per-linter batches.References: