Add blankassign linter #6676
Unanswered
skosovsky
asked this question in
New Linter Proposals
Replies: 1 comment
|
Fake usage of the discussion template... |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Repository URL
https://github.com/skosovsky/blankassign
Analyzer Requirements
go/analysis.go.mod<= 1.25.0.Analyzer Goal
Finds bugs
Analyzer Description
blankassignreports direct single assignments to the blank identifier that silence unused non-error values, such as_ = ctx,_ = result, or_ = compute().It intentionally ignores idiomatic blank identifier uses, including
_, ok :=,_, err :=, range indexes, blank imports, interface assertions, and error-typed RHS values delegated toerrcheck.Analyzer License
MIT
Analyzer License Checks
LICENSE(capitalized).Analyzer Details
init().panic().log.Fatal().os.Exit().Note on
init(): the core analyzer package (blankassignment) does not containinit(). The repository currently also includes agolangci/plugin.goadapter with aninit()function becausegithub.com/golangci/plugin-module-register/registeruses that pattern for golangci-lint v2 module plugin registration. If maintainers require noinit()anywhere in the repository, I can split or drop that adapter before preparing an upstream PR.Repository Details
v1.0.0,v0.1.0(0.0.xare not valid).Repository Recommendations
.gitignore(IDE files, binaries, OS files, etc. should not be committed).mainas the default branch name.Pull Request
Additional context
Latest semver tag:
v0.1.3.Initial publication/tag:
v0.1.0, dated 2026-06-17.Default branch:
main.License: MIT.
Analyzer type:
go/analysis.Analyzer.Linter name:
blankassign.Configuration:
ignorenames for simple identifier RHS values; no external files.Plugin support: golangci-lint v2 module plugin adapter is present.
The motivation is to catch a small but common cleanup failure mode: explicit assignments to
_added to silence unused values during iterative development, refactors, generated changes, or AI-assisted coding. These assignments compile cleanly but often hide incomplete code paths or temporary stubs that escaped review.Relationship to existing linters:
unusedcatches unused declarations, but_ = valueis often used specifically to hide that signal.ineffassignandwastedassignfocus on ineffective ordinary assignments, while_ = valueis an explicit discard.dogsledcatches too many blank identifiers in multi-value assignments, not a single silencing assignment like_ = ctx.errcheckowns ignored errors;blankassignintentionally ignores RHS values whose type implementserror.There was an earlier free-form discussion before the one-month analyzer-age gate was satisfied: #6641. This new discussion uses the official New Linter Proposals form after the age gate.
All reactions