Repository navigation
Description
Linters affected: globwalkignorederror, strconvparseignorederror (both CI-enforced, native + wasm, -test=false)
Bug class: node_filter_too_narrow — same class already fixed in the sibling jsonmarshalignoredeerror linter (issue #39982), but never applied here.
Problem
Both linters register only *ast.AssignStmt in their nodeFilter and require an exact 2-lhs/1-rhs shape with Lhs[1] being the blank identifier:
pkg/linters/globwalkignorederror/globwalkignorederror.go:33,46—nodeFilter := []ast.Node{(*ast.AssignStmt)(nil)}thenif len(assign.Lhs) != 2 || len(assign.Rhs) != 1 { return }pkg/linters/strconvparseignorederror/strconvparseignorederror.go:35,48— identical shape
This only catches the v, _ := f() spelling. It completely misses a bare call statement that discards both return values with no assignment at all, e.g. os.ReadDir(dir) or strconv.Atoi(s) used as a standalone *ast.ExprStmt. That form is legal Go (any call may be used as a statement, silently dropping every return value) and is exactly as silent a failure mode as the _, _ := case both linters already flag.
Reference fix already in the codebase
pkg/linters/jsonmarshalignoredeerror/jsonmarshalignoredeerror.go hit this identical gap (issue #39982) and was fixed by adding *ast.ExprStmt to the node filter alongside *ast.AssignStmt:
nodeFilter := []ast.Node{(*ast.AssignStmt)(nil), (*ast.ExprStmt)(nil)}
...
case *ast.ExprStmt:
checkDiscardedJSONExpr(pass, stmt, noLintIndex)with checkDiscardedJSONExpr unwrapping stmt.X.(*ast.CallExpr) and running the same package/function match used for the assignment case. Neither globwalkignorederror nor strconvparseignorederror has an equivalent branch.
Verified gap, not just theory
pkg/linters/globwalkignorederror/testdata/src/globwalkignorederror/globwalkignorederror.goandpkg/linters/strconvparseignorederror/testdata/src/strconvparseignorederror/strconvparseignorederror.gocontain zeroExprStmttest cases — everybad()/good()/suppressed()fixture uses thex, _ := f()assignment form only.- Both linters are wired into
.github/workflows/cgo.ymlLINTER_FLAGSfor both the native and wasm CI jobs with-test=false, so they are meant to be a complete production gate, not a partial one. - No live production site currently uses the bare-statement form (checked via grep across
pkg/), so this is a latent enforcement gap rather than an active false-negative today — but it is a silent hole in a linter that is already CI-enforced, so any future PR that writesos.ReadDir(dir)orstrconv.Atoi(s)as a bare statement passes the gate unnoticed.
Recommendation
Add an *ast.ExprStmt branch to both linters, mirroring the checkDiscardedJSONExpr helper in jsonmarshalignoredeerror: unwrap stmt.X as *ast.CallExpr, run the existing selector/package-match logic (checkedFuncs for globwalkignorederror, strconvParseFuncs for strconvparseignorederror), and report the same message used for the assignment case. Add one ExprStmt-shaped case to each testdata fixture (want comment included) to lock in coverage.
Validation checklist
-
os.ReadDir(dir)/filepath.Glob(pattern)as a bare statement is flagged byglobwalkignorederror -
strconv.Atoi(s)(and siblings) as a bare statement is flagged bystrconvparseignorederror - Existing assignment-form test cases still pass unchanged
-
nolint:globwalkignorederror/nolint:strconvparseignorederroron the bare-statement form still suppresses correctly
Effort: small — one ExprStmt case per linter, following the exact pattern already proven in jsonmarshalignoredeerror.
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
api.anthropic.com
To allow these domains, add them to the network.allowed list in your workflow frontmatter:
network:
allowed:
- defaults
- "api.anthropic.com"See Network Configuration for more information.
Generated by 🤖 Sergo - Serena Go Expert · claude · agent · 320.4 AIC · ⌖ 7.91 AIC · ⊞ 6.8K · ◷
- expires on Sep 22, 2026, 8:00 PM UTC-08:00
Activity
github-actions commentedon Sep 23, 2026
This issue was automatically closed because it expired on 2026-09-23T04:00:05.216Z.