Repository navigation
Close recurring Go analyzer and ESLint rule blind spots - #65410
Merged
Merged
Conversation
1 task
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix recurring pkg/linters analyzer blind spots
Close recurring Go analyzer and ESLint rule blind spots
Oct 3, 2026
pelikhan
marked this pull request as ready for review
October 3, 2026 19:57
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Several new traversal paths still lose findings across assignment evaluation, terminal branches, loops, and alias mutation.
Review effort: Balanced
Findings: 8
Open (8)
Tie ordering guards to the referenced value · New Preserve zero-iteration paths in loop analysis · New Model continue and goto control flow before checks · New Unwrap parenthesized calls in expression statements · New Do not merge states from terminating branches · New Exclude terminal branches from state merging · New Apply assignment aliases after analyzing RHS · New Preserve aliases while analyzing assignment RHS · New
What changed in this PR
Expands Go and ESLint analyzers to recognize equivalent syntax, aliases, and control-flow patterns.
Changes:
- Improves alias, parenthesis, selector, and entry-point detection.
- Adds branch-aware resource and buffer analysis.
- Adds regression fixtures for reported blind spots.
| File | Description |
|---|---|
pkg/linters/unchecked-slice-index/uncheckedsliceindex.go |
Handles selector-based bounds. |
pkg/linters/unchecked-slice-index/testdata/src/uncheckedsliceindex/uncheckedsliceindex.go |
Tests selector bounds. |
pkg/linters/typeassertionnil/typeassertionnil.go |
Recognizes pointer aliases. |
pkg/linters/typeassertionnil/testdata/src/typeassertionnil/typeassertionnil.go |
Tests pointer aliases. |
pkg/linters/trimleftright/testdata/src/trimleftright/trimleftright.go |
Tests parenthesized cutsets. |
pkg/linters/tolowerequalfold/tolowerequalfold.go |
Snapshots alias state. |
pkg/linters/tolowerequalfold/testdata/src/tolowerequalfold/tolowerequalfold.go.golden |
Updates expected rewrites. |
pkg/linters/tolowerequalfold/testdata/src/tolowerequalfold/tolowerequalfold.go |
Tests reassignment and parentheses. |
pkg/linters/rawloginlib/testdata/src/entrypoint/entrypoint.go |
Adds main-package fixture. |
pkg/linters/rawloginlib/rawloginlib.go |
Exempts named main packages. |
pkg/linters/rawloginlib/rawloginlib_test.go |
Runs entry-point fixture. |
pkg/linters/panic-in-library-code/testdata/src/entrypoint/entrypoint.go |
Adds main-package fixture. |
pkg/linters/panic-in-library-code/panic-in-library-code.go |
Exempts named main packages. |
pkg/linters/panic-in-library-code/panic-in-library-code_test.go |
Runs entry-point fixture. |
pkg/linters/osexitinlibrary/testdata/src/entrypoint/entrypoint.go |
Adds main-package fixture. |
pkg/linters/osexitinlibrary/osexitinlibrary.go |
Exempts named main packages. |
pkg/linters/osexitinlibrary/osexitinlibrary_test.go |
Runs entry-point fixture. |
pkg/linters/nilctxpassed/testdata/src/nilctxpassed/nilctxpassed.go |
Tests parenthesized nil. |
pkg/linters/nilctxpassed/nilctxpassed.go |
Unwraps nil expressions. |
pkg/linters/manualmutexunlock/testdata/src/manualmutexunlock/manualmutexunlock.go |
Tests branch cleanup. |
pkg/linters/logfatallibrary/testdata/src/entrypoint/entrypoint.go |
Adds main-package fixture. |
pkg/linters/logfatallibrary/logfatallibrary.go |
Exempts named main packages. |
pkg/linters/logfatallibrary/logfatallibrary_test.go |
Runs entry-point fixture. |
pkg/linters/lenstringzero/testdata/src/lenstringzero/lenstringzero.go.golden |
Updates expected rewrites. |
pkg/linters/lenstringzero/testdata/src/lenstringzero/lenstringzero.go |
Tests alias reassignment. |
pkg/linters/lenstringzero/lenstringzero.go |
Snapshots alias state. |
pkg/linters/internal/resourcetracker/testdata/src/resourcetracker/resourcetracker.go |
Tests branch cleanup states. |
pkg/linters/internal/resourcetracker/resourcetracker.go |
Adds branch-aware resource tracking. |
pkg/linters/internal/nolint/nolint.go |
Accepts spaced directives. |
pkg/linters/internal/nolint/nolint_test.go |
Tests spaced directives. |
pkg/linters/internal/astutil/astutil.go |
Unwraps string literals. |
pkg/linters/internal/astutil/astutil_test.go |
Tests parenthesized literals. |
pkg/linters/httprespbodyclose/testdata/src/httprespbodyclose/httprespbodyclose.go |
Tests branch response cleanup. |
pkg/linters/httprespbodyclose/httprespbodyclose.go |
Tracks response states across branches. |
pkg/linters/fprintferrorunchecked/testdata/src/fprintferrorunchecked/fprintferrorunchecked.go |
Tests bare Fprint calls. |
pkg/linters/fprintferrorunchecked/fprintferrorunchecked.go |
Analyzes expression statements. |
pkg/linters/fileclosenotdeferred/testdata/src/fileclosenotdeferred/fileclosenotdeferred.go |
Tests branch file cleanup. |
pkg/linters/errstringmatch/testdata/src/errstringmatch/errstringmatch.go |
Tests parenthesized strings. |
pkg/linters/contextcancelnotdeferred/testdata/src/contextcancelnotdeferred/contextcancelnotdeferred.go |
Tests branch cancellation. |
pkg/linters/closeerrorunchecked/testdata/src/closeerrorunchecked/closeerrorunchecked.go |
Tests parenthesized Close calls. |
pkg/linters/closeerrorunchecked/closeerrorunchecked.go |
Unwraps Close calls. |
pkg/linters/bufioscannererunchecked/testdata/src/basic/good.go |
Tests cross-block checks. |
pkg/linters/bufioscannererunchecked/testdata/src/basic/bad.go |
Tests unreachable checks. |
pkg/linters/bufioscannererunchecked/bufioscannererunchecked.go |
Propagates following statements. |
pkg/linters/bufferresetbeforereuse/testdata/src/a/a.go |
Tests branch and loop states. |
pkg/linters/bufferresetbeforereuse/bufferresetbeforereuse.go |
Adds control-flow state analysis. |
pkg/linters/blankassigncomma/testdata/src/blankassigncomma/blankassigncomma.go |
Tests hash writer exemption. |
pkg/linters/blankassigncomma/blankassigncomma.go |
Exempts hash WriteString calls. |
eslint-factory/src/rules/no-unsafe-catch-error-property.ts |
Tracks catch aliases. |
eslint-factory/src/rules/no-unsafe-catch-error-property.test.ts |
Tests catch aliases and mutation. |
eslint-factory/src/rules/no-math-minmax-array-spread.ts |
Recognizes bounded arrays. |
eslint-factory/src/rules/no-math-minmax-array-spread.test.ts |
Tests bounded and mutable arrays. |
eslint-factory/src/rules/no-github-request-interpolated-route.ts |
Recognizes fallback clients. |
eslint-factory/src/rules/no-github-request-interpolated-route.test.ts |
Tests fallback client aliases. |
Comment on lines
+253
to
+254
| (varName !== frame.varName && catchParamUnchangedSinceAlias(frame, memberExpr) && (isGuardedByAncestorBranch(sourceCode, memberExpr, frame.varName) || hasPriorEarlyExitInstanceofGuard(sourceCode, memberExpr, frame.varName))) || | ||
| isCallOrderingGuarded(sourceCode, memberExpr, frame.safeCalls) |
Comment on lines
+239
to
+240
| if nested, ok := n.(*ast.BlockStmt); ok { | ||
| analyzeStraightLineBlock(pass, nested, written, read, generatedFiles, noLintIndex) |
Comment on lines
+142
to
+143
| if _, returns := stmt.(*ast.ReturnStmt); returns { | ||
| return false |
| if filecheck.ShouldSkipFilename(position.Filename, generatedFiles) { | ||
| return | ||
| } | ||
| call, ok := stmt.X.(*ast.CallExpr) |
Comment on lines
+103
to
+107
| for pos, then := range variants { | ||
| if other, ok := elseStates[key][pos]; ok { | ||
| then.hasManualClose = then.hasManualClose || other.hasManualClose | ||
| then.hasDeferClose = then.hasDeferClose && other.hasDeferClose | ||
| if !then.manualClosePos.IsValid() { |
Comment on lines
+142
to
+145
| if other, ok := elseStates[key][pos]; ok { | ||
| then.hasManual = then.hasManual || other.hasManual | ||
| then.hasDefer = then.hasDefer && other.hasDefer | ||
| } |
Comment on lines
258
to
259
| case *ast.AssignStmt: | ||
| collectLenStringAliasesFromAssignStmt(pass, n, aliases) |
Comment on lines
159
to
160
| case *ast.AssignStmt: | ||
| collectAliasesFromAssignStmt(pass, n, aliases) |
Contributor
|
🎉 This pull request is included in a new release. Release: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Several analyzers missed equivalent Go syntax or lost findings across reassignment and control-flow boundaries. Related ESLint rules also missed client aliases and catch aliases, or misclassified bounded arrays.
fmt.Fprint*calls, spacednolintdirectives, and non-cmdmain packages.For example, the analyzers now distinguish an earlier valid finding from a later reassignment: