Skip to content

Close recurring Go linter analyzer blind spots - #67544

Merged
pelikhan merged 2 commits into
mainfrom
copilot/aw-top-10-close-recurring-go-linter-analyzer-blind
Oct 11, 2026
Merged

pelikhan merged 2 commits into
mainfrom
copilot/aw-top-10-close-recurring-go-linter-analyzer-blind

Conversation

Copilot AI commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Several analyzers missed function aliases and bare discarded-error calls; coverage gating could select the wrong block or file, and deferinloop misreported range-over-function iterators.

  • Shared AST matching: Resolve calls through local function-value aliases and match bare expression statements. Extend discarded-error checks for filepath.Glob, os.ReadDir, and strconv parsing; reuse the matcher for JSON calls.
  • Coverage matching: Use source columns to select the relevant coverage block and prefer the most-specific filename match deterministically.
  • Iterator semantics: Treat range-over-function bodies as defer scope boundaries.
r := reflect.DeepEqual
r(a, b) // detected

for range iterator {
	defer cleanup() // not flagged: runs for each yield
}

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix recurring Go linter analyzer blind spots and improve coverage Close recurring Go linter analyzer blind spots Oct 11, 2026
Copilot AI requested a review from pelikhan October 11, 2026 00:35
@pelikhan
pelikhan marked this pull request as ready for review October 11, 2026 00:57
Copilot AI balanced review requested due to automatic review settings October 11, 2026 00:58
@pelikhan
pelikhan merged commit fed2eb5 into main Oct 11, 2026
3 checks passed
@pelikhan
pelikhan deleted the copilot/aw-top-10-close-recurring-go-linter-analyzer-blind branch October 11, 2026 00:58

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.

🟡 Changes recommended

The range-over-function exemption contradicts Go defer semantics, while alias resolution can misclassify mutable aliases.

4 open findings
What changed in this PR

This PR addresses Go analyzer blind spots in call matching, coverage gating, and loop detection.

Changes:

  • Adds function-alias and bare discarded-call matching.
  • Makes coverage lookup column-aware and deterministic.
  • Adds special handling for range-over-function loops.
File Description
pkg/​linters/​internal/​astutil/​astutil.go Extends shared call matching and alias resolution.
pkg/​linters/​internal/​coverage/​coverage.go Improves coverage block and filename selection.
pkg/​linters/​internal/​coverage/​coverage_test.go Tests column and path specificity.
pkg/​linters/​deferinloop/​deferinloop.go Changes range-over-function handling.
pkg/​linters/​deferinloop/​testdata/​src/​deferinloop/​deferinloop.go Adds iterator-loop fixture.
pkg/​linters/​globwalkignorederror/​globwalkignorederror.go Detects bare discarded calls.
pkg/​linters/​globwalkignorederror/​testdata/​src/​globwalkignorederror/​globwalkignorederror.go Adds bare-call fixtures.
pkg/​linters/​jsonmarshalignoredeerror/​jsonmarshalignoredeerror.go Reuses shared discarded-call matching.
pkg/​linters/​reflect-deepequal-usage/​testdata/​src/​a/​a.go Enables alias detection assertion.
pkg/​linters/​strconvparseignorederror/​strconvparseignorederror.go Detects bare discarded parse calls.
pkg/​linters/​strconvparseignorederror/​testdata/​src/​strconvparseignorederror/​strconvparseignorederror.go Adds bare-call fixture.

🧠 Review effort: Balanced


💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +77 to +80
if pass.TypesInfo != nil {
if typ := pass.TypesInfo.TypeOf(node.X); typ != nil {
if _, ok := typ.Underlying().(*types.Signature); ok {
return false
blank, ok := secondLHS.(*ast.Ident)
if !ok || blank.Name != "_" {
case *ast.ExprStmt:
call, ok = stmt.X.(*ast.CallExpr)
Comment on lines +125 to +129
func packageFunctionAlias(pass *analysis.Pass, obj types.Object, seen map[types.Object]bool) (string, string, bool) {
if obj == nil {
return "", "", false
}
pkgName, ok := pass.TypesInfo.Uses[ident].(*types.PkgName)
if !ok || pkgName.Imported() == nil {
if seen == nil {
Comment on lines +150 to +154
value := packageFunctionAliasInitializer(pass, node, obj)
if value == nil {
return true
}
pkgPath, funcName, _ = packageFunction(pass, value, seen)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[AW Top 10] 06 Close recurring Go linter analyzer blind spots

3 participants