Repository navigation
[linter-miner] Add ignored local error linter - #76620
Conversation
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
|
✅ PR Specification Reviewer completed successfully! PR Specification 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.
|
|
✅ PR Code Quality Reviewer completed the code quality review. PR Code Quality ReviewerOutcome: The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ 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.
|
|
✅ Ponytail Reviewer completed successfully!
|
This comment has been minimized.
This comment has been minimized.
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅
|
There was a problem hiding this comment.
What this change does: Adds an analyzer for discarded errors from functions in the gh-aw module and registers it with the linter suite.
One signature lookup can be simplified as noted inline.
Verdict: Ship.
Lean: -8 lines possible.
Generated by ✂️ Ponytail Reviewer for #76620 · codex · routed: gpt61 medium · ~5 AIC · ⌖ ~1 AIC · ⊞ 181
Comment /ponytail to run again
| } | ||
|
|
||
| var callType types.Type | ||
| if selector, isSelector := astutil.UnwrapParenExpr(call.Fun).(*ast.SelectorExpr); isSelector { |
There was a problem hiding this comment.
Should fix: For calls such as testsupport.Error() and receiver{}.methodError(), TypesInfo.TypeOf(call.Fun) already gives the call signature. Use that lookup for selectors too and remove this branch; it avoids maintaining two paths for the same result and saves 8 lines.
There was a problem hiding this comment.
Simplified signature lookup to use TypesInfo.TypeOf for all callees while preserving package resolution. Addressed in 6943f8f.
Comment MemoryPeek at saved memory (pr-code-quality-reviewer)Note This comment is managed by comment memory.Expand the saved memory block to view or edit the persistent context for this thread.
|
There was a problem hiding this comment.
Found two correctness gaps in the new analyzer: several AST forms that discard call results are not traversed, and concrete error implementations are not recognized as error results. These can produce silent false negatives in the linter. Inline comments provide repro patterns and suggested fixes. Review was static; tests were not run per review instructions.
🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~3 AIC · ⌖ ~1 AIC · ⊞ 1.6K
Comment /review to run again
| return signature, ok | ||
| } | ||
|
|
||
| func isErrorType(t types.Type) bool { |
There was a problem hiding this comment.
types.Identical only recognizes the builtin error interface. A module function returning a concrete type that implements error (for example *MyError) is still an error result that can be discarded, but _ = f() will be silently missed. Consider checking assignability/implementation against the error interface and add a test case, or document this intentional restriction.
There was a problem hiding this comment.
Switched to the shared nolint.ImplementsError helper and added concrete and extended error-type fixtures. Addressed in 6943f8f.
| return nil, err | ||
| } | ||
|
|
||
| nodeFilter := []ast.Node{(*ast.AssignStmt)(nil), (*ast.ExprStmt)(nil)} |
There was a problem hiding this comment.
This traversal only considers AssignStmt and ExprStmt, so discarded errors in defer ghaw.DoThing(), go ghaw.DoThing(), and blank assignments in declarations such as var _ = ghaw.DoThing() are missed. Those are valid discard forms and can hide exactly the failures this analyzer is intended to catch. Please handle the corresponding AST nodes (or explicitly narrow and document the scope), with regression tests.
There was a problem hiding this comment.
Added handling for ValueSpec, defer, and go statements, with regression fixtures for the discarded results. Addressed in 6943f8f.
🏗️ Design Decision Gate — ADR RequiredThis PR makes significant changes to core business logic (231 new lines in 📄 Draft ADR committed:
📋 What to do next
Checked for an existing ADR in the PR body, on the PR branch ( Once an ADR is linked in the PR body, this gate will re-run and verify the implementation matches the decision. 🧾 Open items in the draft
❓ Why ADRs MatterADRs create a searchable, permanent record of why the codebase looks the way it does. Future contributors (and your future self) will thank you. 📋 Michael Nygard ADR Format ReferenceAn ADR must contain these four sections to be considered complete:
All ADRs are stored in
|
There was a problem hiding this comment.
🟡 Changes recommended
The analyzer misses discarded errors in explicitly instantiated generic calls, blank-assigned declarations, and results whose declared types implement error but are not the built-in error interface.
3 open issues
1 file not reviewed
pkg/linters/ignoredlocalerror/testdata/src/github.com/github/gh-aw/pkg/linters/ignoredlocalerror/generated.go: Generated file
What changed in this PR
Adds ignoredlocalerror to gh-aw’s custom Go analyzers to detect discarded errors from functions within the module.
Changes:
- Detects bare calls and blank-assigned error results, with generated-file exclusions and
nolintsupport. - Adds analyzer tests and fixtures for local functions, methods, and imported functions.
- Registers and documents the analyzer while deferring CI enforcement.
| File | Description |
|---|---|
pkg/linters/spec_test.go |
Includes the analyzer in documentation checks. |
pkg/linters/registry.go |
Registers the analyzer. |
pkg/linters/README.md |
Documents the analyzer and its package. |
pkg/linters/ignoredlocalerror/testdata/src/github.com/github/gh-aw/pkg/testsupport/errors.go |
Provides imported error-returning test functions. |
pkg/linters/ignoredlocalerror/testdata/src/github.com/github/gh-aw/pkg/linters/ignoredlocalerror/ignoredlocalerror.go |
Covers detection and suppression cases. |
pkg/linters/ignoredlocalerror/testdata/src/github.com/github/gh-aw/pkg/linters/ignoredlocalerror/generated.go |
Verifies generated-file exclusion. |
pkg/linters/ignoredlocalerror/ignoredlocalerror.go |
Implements discarded-error detection. |
pkg/linters/ignoredlocalerror/ignoredlocalerror_test.go |
Runs the analyzer against fixtures. |
pkg/linters/doc.go |
Updates the analyzer catalog and count. |
pkg/linters/doc_sync_test.go |
Records deferred CI enforcement. |
Review effort: Balanced (auto)
| nodeFilter := []ast.Node{(*ast.AssignStmt)(nil), (*ast.ExprStmt)(nil)} | ||
| return analyzerutil.Preorder(pass, nodeFilter, func(n ast.Node) { | ||
| analyzeStmt(pass, n, generatedFiles, nolintIndex) | ||
| }) |
| } | ||
|
|
||
| func callSignature(pass *analysis.Pass, call *ast.CallExpr) (*types.Signature, bool) { | ||
| pkgPath, _, ok := astutil.PackageCall(pass, call) |
| } | ||
|
|
||
| func isErrorType(t types.Type) bool { | ||
| return types.Identical(t, types.Universe.Lookup("error").Type()) |
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /diagnosing-bugs, /tdd, /codebase-design and /grill-with-docs. Requesting changes on one correctness gap (generic calls) and missing test coverage.
📋 Key Themes & Highlights
Key Themes
- Correctness: generic calls such as
pkg.F[int]()that returnerrorare silently missed (false negative), becausecallSignaturedoes not unwrapIndexExpr/IndexListExpr. - Test coverage: the multi-value blank assign, parenthesised calls and generic calls have no
// wantcases. - Reuse:
isErrorTypeduplicatesnolint.ImplementsError/astutil.UniverseErrorInterface(). - Docs:
ignoredlocalerroris innotYetEnforcedbut missing from the README "excluded from CI enforcement" notes.
Positive Highlights
- ✅ Clean, self-contained analyzer with
nolintand generated-file skip support. - ✅ Registry,
doc.gocount (94 to 95) and README analyzer entries are consistent forignoredlocalerror. - ✅
TestAnalyzerpasses, andgofmtis clean.
Notes on Scope
pr-triagewas unavailable, so skill selection used the fallback heuristic onpr-meta.jsonand the diff.TestDocGo_AnalyzersMatchREADMEandTestDocSurfacesMatchRegistryAndSpecListfail on five analyzers this PR does not touch (deferrerrorunchecked,reflectdeepequalusage,unchecked_deferredclose,uncheckedsliceindex,walkdirignoredeerror).ignoredlocalerroritself matches all surfaces. This looks like pre-existing drift, but I did not confirm it against the base commit.
@copilot please address the review comments above.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~8 AIC · ⌖ ~2 AIC · ⊞ 6.6K
Comment /matt to run again
| func callSignature(pass *analysis.Pass, call *ast.CallExpr) (*types.Signature, bool) { | ||
| pkgPath, _, ok := astutil.PackageCall(pass, call) | ||
| if !ok { | ||
| if selector, isSelector := astutil.UnwrapParenExpr(call.Fun).(*ast.SelectorExpr); isSelector { |
There was a problem hiding this comment.
[/diagnosing-bugs] Generic calls are not flagged. A probe with testsupport.Generic[int]() (an ExprStmt that returns only error) produced no diagnostic, so this is a false negative. For an instantiated call, call.Fun is an *ast.IndexExpr, not an *ast.SelectorExpr, so the selector lookup at lines 101-107 never resolves the package path.
💡 Suggested fix
Unwrap instantiation before the selector check, then add a // want case for Generic[int]() to the testdata:
func unwrapInstantiation(expr ast.Expr) ast.Expr {
switch e := astutil.UnwrapParenExpr(expr).(type) {
case *ast.IndexExpr:
return e.X
case *ast.IndexListExpr:
return e.X
}
return expr
}Apply it wherever astutil.UnwrapParenExpr(call.Fun) feeds the selector lookup in callSignature.
@copilot please address this.
There was a problem hiding this comment.
Package lookup now unwraps IndexExpr and IndexListExpr, while signature lookup uses the instantiated callee. Regression fixtures cover both forms. Addressed in 6943f8f.
| } | ||
|
|
||
| func isErrorType(t types.Type) bool { | ||
| return types.Identical(t, types.Universe.Lookup("error").Type()) |
There was a problem hiding this comment.
[/codebase-design] isErrorType re-implements error detection that already exists in nolint.ImplementsError (pkg/linters/internal/nolint/nolint.go) and astutil.UniverseErrorInterface(). Sharing one helper keeps error-type semantics consistent across analyzers. Check semantics before swapping: types.Identical here is stricter than an Implements check and may treat named error types differently.
@copilot please address this.
There was a problem hiding this comment.
Error result checks now use the shared nolint.ImplementsError helper. Added concrete and extended error-type coverage. Addressed in 6943f8f.
|
|
||
| func badCalls() { | ||
| localError() // want `error return from a github.com/github/gh-aw function is discarded` | ||
| _, _ = localResult() // want `error return from a github.com/github/gh-aw function is discarded` |
There was a problem hiding this comment.
[/tdd] Several discard shapes are flagged but not pinned by any test: the multi-value blank assign a, _ = 1, testsupport.Error(), the parenthesised (testsupport.Error()) statement, and the generic call covered above. Add each as a // want case. The first two should pass on the current code. The generic case will fail until the false negative is fixed. Without these cases, a refactor of the len(rhs) branch or of callSignature could change behaviour unnoticed.
@copilot please address this.
There was a problem hiding this comment.
Added regression cases for the multi-value blank assignment and parenthesized call, alongside the generic-call cases. Addressed in 6943f8f.
| "fprintferrorunchecked": "existing production violations need remediation before enforcement; nolint suppression already works", | ||
| "goroutineresourceleak": "requires an enforcement-readiness audit before native and WebAssembly CI enable it", | ||
| "hardcodedfilepath": "requires an enforcement audit after the same-package constant fix (#52428)", | ||
| "ignoredlocalerror": "existing ignored local errors need review before CI enforcement", |
There was a problem hiding this comment.
[/grill-with-docs] ignoredlocalerror is parked in notYetEnforced with the reason: existing ignored local errors need review before CI enforcement. The "excluded from CI enforcement" notes in pkg/linters/README.md (around lines 459-461) do not mention it, while the peer entries typeassertionnil, unchecked_deferredclose and walkdirignoredeerror each have a bullet there. Add one for consistency, naming the same blocker.
@copilot please address this.
There was a problem hiding this comment.
Added the excluded-from-CI note for ignoredlocalerror with the existing-error review blocker. Addressed in 6943f8f.
|
🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:
Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering. Structured data{
"completed_task": 0,
"head": "8daa5233fa11f028a7513ca2c7ad6a187a36a515",
"kind": "requested",
"schema_version": "1",
"state": "03020d3e0f59b52d424bf1cd46f7164bdee7eb68d53cb7a8774af0ee056910f2",
"work": [
"0fb829fcc365175db5780590ce32fd2f22b484bb05518ab5d1960672fb09d852",
"31d9aeffd180a945244cd1e032eb73358bef3b5909ede172e70195df823075e0",
"43b3dc21dbb0041c93400316c8bd040441d4296fa5974f2d6e620d42e507463e",
"5619f039459fec101ee27c968fe851323467193e53c741bbe8990d76bae32cf4",
"739532412c31b38a15aa0587973fea60d2003310979e39bde6559f0275c2f8e8",
"d73a27c32bc30166fcb2403098ceac525b82a736606d5f422c1bb24b041885fa",
"dbb513dce94086a1d4f70f5270a6871134826a2c3d342cda07205b85052fdb60"
],
"workflow": "pr-sous-chef"
}
|
|
Category: feature | Risk: medium | Score: 58 (impact 31 + urgency 15 + quality 12) | Action: batch_review | Batch: pr-batch:eligible-copilot
|
…gnored-local-error Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Merged |
|
🎉 This pull request is included in a new release. Release: |

Discarded errors from
github.com/github/gh-awfunctions can go unnoticed, especially witherrcheckdisabled. Add a custom analyzer to flag these cases.//nolint:ignoredlocalerror.For example, both calls are reported when the functions return an error: