Skip to content

[linter-miner] Add globwalkignorederror linter: flag discarded errors from filepath.Glob/os.ReadDir #51149

Description

@github-actions

Summary

Adds a new custom go/analysis linter, globwalkignorederror, under pkg/linters/globwalkignorederror/, following the pkg/linters/largefunc and pkg/linters/strconvparseignorederror conventions.

What it catches: filepath.Glob(...) and os.ReadDir(...) calls whose error return is discarded via the blank identifier (files, _ := filepath.Glob(...)), which silently masks malformed glob patterns or unreadable directories and lets the caller proceed with an empty/zero result as if it were success.

Evidence (Step 2 mining)

A code-pattern-scan of pkg/ with Serena/grep found this exact discard pattern already present in production code, e.g.:

  • pkg/cli/enable.goymlFiles, _ := filepath.Glob(...)
  • pkg/cli/compile_pipeline.godata.existingLockFiles, _ = filepath.Glob(...)
  • pkg/cli/audit_job.go

None of the ~63 existing linters (e.g. jsonmarshalignoredeerror, strconvparseignorederror, ioutildeprecated) cover filepath.Glob/os.ReadDir error handling, so this is a genuinely uncovered gap with clear real-world instances and low false-positive risk (only flags the exact x, _ := f(...) assignment shape).

Changes

  • pkg/linters/globwalkignorederror/globwalkignorederror.go — the analyzer (Analyzer var, run, nolint + generated-file support, matching strconvparseignorederror structure)
  • pkg/linters/globwalkignorederror/globwalkignorederror_test.goanalysistest-based test
  • pkg/linters/globwalkignorederror/testdata/src/globwalkignorederror/{globwalkignorederror.go,generated.go} — fixtures (bad/good/suppressed cases + generated-file skip case)
  • pkg/linters/registry.go — registers globwalkignorederror.Analyzer in All()
  • pkg/linters/doc.go, pkg/linters/README.md, pkg/linters/spec_test.go — documentation/spec-consistency updates (analyzer count 63→64)

Verification

  • go build ./pkg/linters/... ./cmd/linters/... — passes
  • go test ./pkg/linters/... — all packages pass, including the new package and the doc/spec consistency tests (TestRegistryMatchesDocumentation, TestDocGo_CountMatchesBullets)
  • gofmt -l — clean
  • go vet — clean

Warning

Protected Files — Push Permission Denied

This was originally intended as a pull request, but the patch modifies protected files. A human must create the pull request manually.

Protected files
  • README.md

The push was rejected because GitHub Actions does not have workflows permission to push these changes, and is never allowed to make such changes, or other authorization being used does not have this permission.

Create the pull request manually
# Download the patch from the workflow run
gh run download 31203064839 -n agent -D /tmp/agent-31203064839

# Create a new branch
git checkout -b linter-miner/globwalkignorederror-1ff3e7f2c4310245 main

# Apply the patch (--3way handles cross-repo patches)
git am --3way /tmp/agent-31203064839/aw-linter-miner-globwalkignorederror.patch

# Push the branch and create the pull request
git push origin linter-miner/globwalkignorederror-1ff3e7f2c4310245
gh pr create --title '[linter-miner] Add globwalkignorederror linter: flag discarded errors from filepath.Glob/os.ReadDir' --base main --head linter-miner/globwalkignorederror-1ff3e7f2c4310245 --repo github/gh-aw

Generated by Linter Miner · auto · 186.8 AIC · ⌖ 14.9 AIC · ⊞ 7.7K ·

  • expires on Aug 14, 2026, 9:54 AM UTC-08:00

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions