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.
[linter-miner] Add type-assertion-ok-discarded linter #61388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
[linter-miner] Add type-assertion-ok-discarded linter #61388
Changes from all commits
dbb1104dceac41011f024676597e227b4daFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new analyzer is registered but the documentation surfaces required by
pkg/lintersare not updated to match, which breaks the build:pkg/linters/README.mdhas notypeassertionokdiscardedrow in the "Subpackages" table (or the top summary list).pkg/linters/doc.godoc comment doesn't listtypeassertionokdiscarded.pkg/linters/spec_test.go'sdocumentedAnalyzers()doesn't include an entry for it.Running
go test ./pkg/linters/...fails withTestDocSurfacesMatchRegistryAndSpecListbecause the registry (72 analyzers) no longer matches the documented list (71 analyzers). Please add the corresponding README row,doc.gobullet, anddocumentedAnalyzers()entry fortypeassertionokdiscardedso the suite passes.@copilot please address this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[/tdd] The analyzer's
isTwoValueBlankOkAssertionexplicitly handles*ast.ValueSpecto cover bothvarandconsttwo-value declarations, but the fixtures only exercise thevarform (BadBlankOkVarDecl). There's noconstcase, so a regression in const-handling wouldn't be caught.💡 Suggested addition
Note: type assertions aren't valid in
constinitializers in real Go, so this branch ofValueSpechandling may actually be dead/unreachable forconst. Worth double-checking whether theValueSpeccase ever fires outsidevar, and either adding a comment clarifying that, or removing the now-misleading "var/const" wording in the code comment ifconstcan't apply here.@copilot please address this.
Uh oh!
There was an error while loading. Please reload this page.