You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.:
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.go — analysistest-based test
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 · ◷
Summary
Adds a new custom
go/analysislinter,globwalkignorederror, underpkg/linters/globwalkignorederror/, following thepkg/linters/largefuncandpkg/linters/strconvparseignorederrorconventions.What it catches:
filepath.Glob(...)andos.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.go—ymlFiles, _ := filepath.Glob(...)pkg/cli/compile_pipeline.go—data.existingLockFiles, _ = filepath.Glob(...)pkg/cli/audit_job.goNone of the ~63 existing linters (e.g.
jsonmarshalignoredeerror,strconvparseignorederror,ioutildeprecated) coverfilepath.Glob/os.ReadDirerror handling, so this is a genuinely uncovered gap with clear real-world instances and low false-positive risk (only flags the exactx, _ := f(...)assignment shape).Changes
pkg/linters/globwalkignorederror/globwalkignorederror.go— the analyzer (Analyzervar,run, nolint + generated-file support, matchingstrconvparseignorederrorstructure)pkg/linters/globwalkignorederror/globwalkignorederror_test.go—analysistest-based testpkg/linters/globwalkignorederror/testdata/src/globwalkignorederror/{globwalkignorederror.go,generated.go}— fixtures (bad/good/suppressed cases + generated-file skip case)pkg/linters/registry.go— registersglobwalkignorederror.AnalyzerinAll()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/...— passesgo test ./pkg/linters/...— all packages pass, including the new package and the doc/spec consistency tests (TestRegistryMatchesDocumentation,TestDocGo_CountMatchesBullets)gofmt -l— cleango vet— cleanWarning
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.mdThe push was rejected because GitHub Actions does not have
workflowspermission 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