wgdonenotdeferred: parenthesized Done() statement escapes non-deferred detection (paren_unwrap_gap)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
Research direction
Read pkg/linters/wgdonenotdeferred/wgdonenotdeferred.go at inspectBody and compare its call handling with the referenced astutil.MatchDiscardedErrorCall or resourcetracker.go patterns. Add a parenthesized Done() case to testdata/src/wgdonenotdeferred/wgdonenotdeferred.go, then run the existing wgdonenotdeferred tests. Done means the parenthesized non-deferred call produces the expected diagnostic.
Written by the indexing model from the issue text.
Description
Issue Type: Correctness bug (false negative) - missing ParenExpr unwrap, established paren_unwrap_gap class
Location: pkg/linters/wgdonenotdeferred/wgdonenotdeferred.go:86 (inspectBody)
Problem: The statement-level flag check does a bare type assertion with no ParenExpr unwrap first:
if call, ok := exprStmt.X.(*ast.CallExpr); ok { if isWaitGroupDone(pass, call) { ... } }
Per the Go spec ExpressionStmt grammar, function and method calls used as standalone statements may be parenthesized (the spec own example shows (<-ch) as valid). So a non-deferred call written as (wg.Done()) has exprStmt.X resolve to *ast.ParenExpr rather than *ast.CallExpr, the type assertion fails silently, and the loop moves on without ever calling isWaitGroupDone - the deadlock-risk diagnostic never fires for this exact shape, even though it is a straightforward Done() call with the exact same missing-defer bug the linter exists to catch.
Impact: Severity: medium (false negative, not false positive - a real deadlock-risk pattern is silently missed). wgdonenotdeferred is CI-enforced on BOTH native and wasm targets (.github/workflows/cgo.yml:1668 and :1695), so this gap is live in the enforced linter set, not latent. testdata/src/wgdonenotdeferred/wgdonenotdeferred.go has zero coverage of a parenthesized Done() call in either the Bad or Good fixture sections - the gap would not be caught by the existing test suite.
This is the same established pattern class already fixed in several sibling linters (closeerrorunchecked, typeassertionnil, walkdirignoredeerror, astutil.MatchDiscardedErrorCall, resourcetracker.go), applied here for the first time to wgdonenotdeferred, which had previously only been audited for the unrelated adjacent_defer_assumption and scope_boundary_funclit classes (both confirmed clean in prior runs) but never for this one.
Recommendation: Call astutil.UnwrapParenExpr(exprStmt.X) before the *ast.CallExpr assertion at line 86, mirroring the fix already applied in astutil.MatchDiscardedErrorCall and resourcetracker.go inspectNode. Add a parenthesized-call case to testdata (e.g. a BadParenthesized function with (wg.Done()) as a bare statement, expecting the same diagnostic) to lock in the fix.
Validation: Existing wgdonenotdeferred_test.go test suite plus the new parenthesized-call testdata case should both pass after the fix; no interaction expected with the loop-boundary or FuncLit-boundary logic since the fix only affects the initial type assertion.
Estimated Effort: Small (single UnwrapParenExpr call plus one testdata case).
Dedup check: gh api search/issues for wgdonenotdeferred+paren and wgdonenotdeferred alone found no prior issue describing this specific gap (only an unrelated closed refactor-clustering issue and CI-enforcement/scope-boundary issues, all already resolved).
Generated by 🤖 Sergo - Serena Go Expert · claude · agent · ~181 AIC · ⌖ ~1 AIC · ⊞ 5.4K · ◷
- expires on Oct 29, 2026, 8:00 PM UTC-08:00
- Dominant language
- Go
- Stars
- 5.4k
- Forks
- 596
- Avg merge
- 3h 40m
- Merged PRs (30d)
- 830
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from github/gh-aw
-
automation models
Difficulty 1/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
automated-analysis code-quality cookie testing
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
automated conformance safe-outputs
Difficulty 1/5 Under an hour Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
automated conformance safe-outputs
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
cookie eslint
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
Similar issues
-
compress: block buffers get re-zeroed on every call, and the zeroing is immediately overwrittenOpen
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ClickHouse/ch-go#1218 ·
Maintainers usually reply within 13 days
-
effort:s impact:low raised-by:reviewer risk:low
Difficulty 1/5 Under an hour Newbie friendliness 84/100
medici-finance/assay#4251 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
golang-migrate/migrate#1457 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 1 day
-
affects-6.5.0 bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day