Skip to content

Close recurring Go analyzer and ESLint rule blind spots - #65410

Merged
pelikhan merged 4 commits into
mainfrom
copilot/fix-recurring-analyzer-blind-spots
Oct 3, 2026
Merged

pelikhan merged 4 commits into
mainfrom
copilot/fix-recurring-analyzer-blind-spots

Conversation

Copilot AI commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

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.

  • Go syntax and aliases: Reuse the shared parenthesis helper, recognize pointer type aliases, and preserve alias state at each comparison.
  • Go control flow: Track resource cleanup across branches and scanner error checks across block boundaries. Cover selector-based slice bounds, bare fmt.Fprint* calls, spaced nolint directives, and non-cmd main packages.
  • ESLint: Recognize bounded array spreads, fallback and conditional Octokit clients, and catch-error aliases without overlooking later mutation.
  • Regression coverage: Add focused fixtures for each reported gap, including cases that must not produce a diagnostic.

For example, the analyzers now distinguish an earlier valid finding from a later reassignment:

n := len(s)
_ = n == 0 // report
n = 1
_ = n == 0 // do not report

Copilot AI and others added 3 commits October 3, 2026 19:27
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
Copilot AI requested a review from pelikhan October 3, 2026 19:46
@pelikhan
pelikhan marked this pull request as ready for review October 3, 2026 19:57
Copilot AI balanced review requested due to automatic review settings October 3, 2026 19:57
@pelikhan
pelikhan merged commit 2912a5b into main Oct 3, 2026
1 check passed
@pelikhan
pelikhan deleted the copilot/fix-recurring-analyzer-blind-spots branch October 3, 2026 19:57

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.

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 Medium severity

Open (8)
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)
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.91.0

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] 10 Close recurring pkg/linters analyzer blind spots

3 participants