mirror of https://github.com/golang/go.git
internal/lsp/source: disable the useany analyzer by default
This analyzer was written at a time when any was only allowed in
constraints, and usage of any vs interface{} was more likely to be
confusing.
Any is now allowed anywhere, and so it is inconsistent to suggest it
only for constraints. However, we can't suggest any over interface{}
everywhere, as that would be incredibly noisy.
Perhaps we should remove this analyzer, but for now simply change it to
off by default.
Change-Id: Ib9726bdb835808d69827c6cd8e4a58dc5d83ad0e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/387614
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
This commit is contained in:
parent
b7d29496b7
commit
258e473066
|
|
@ -574,7 +574,7 @@ Another example is about non-pointer receiver:
|
|||
|
||||
check for constraints that could be simplified to "any"
|
||||
|
||||
**Enabled by default.**
|
||||
**Disabled by default. Enable it by setting `"analyses": {"useany": true}`.**
|
||||
|
||||
## **fillreturns**
|
||||
|
||||
|
|
|
|||
|
|
@ -406,7 +406,7 @@ var GeneratedAPIJSON = &APIJSON{
|
|||
{
|
||||
Name: "\"useany\"",
|
||||
Doc: "check for constraints that could be simplified to \"any\"",
|
||||
Default: "true",
|
||||
Default: "false",
|
||||
},
|
||||
{
|
||||
Name: "\"fillreturns\"",
|
||||
|
|
@ -922,9 +922,8 @@ var GeneratedAPIJSON = &APIJSON{
|
|||
Doc: "checks for unused writes\n\nThe analyzer reports instances of writes to struct fields and\narrays that are never read. Specifically, when a struct object\nor an array is copied, its elements are copied implicitly by\nthe compiler, and any element write to this copy does nothing\nwith the original object.\n\nFor example:\n\n\ttype T struct { x int }\n\tfunc f(input []T) {\n\t\tfor i, v := range input { // v is a copy\n\t\t\tv.x = i // unused write to field x\n\t\t}\n\t}\n\nAnother example is about non-pointer receiver:\n\n\ttype T struct { x int }\n\tfunc (t T) f() { // t is a copy\n\t\tt.x = i // unused write to field x\n\t}\n",
|
||||
},
|
||||
{
|
||||
Name: "useany",
|
||||
Doc: "check for constraints that could be simplified to \"any\"",
|
||||
Default: true,
|
||||
Name: "useany",
|
||||
Doc: "check for constraints that could be simplified to \"any\"",
|
||||
},
|
||||
{
|
||||
Name: "fillreturns",
|
||||
|
|
|
|||
|
|
@ -694,8 +694,8 @@ func (o *Options) Clone() *Options {
|
|||
ClientOptions: o.ClientOptions,
|
||||
InternalOptions: o.InternalOptions,
|
||||
Hooks: Hooks{
|
||||
GoDiff: o.Hooks.GoDiff,
|
||||
ComputeEdits: o.Hooks.ComputeEdits,
|
||||
GoDiff: o.GoDiff,
|
||||
ComputeEdits: o.ComputeEdits,
|
||||
GofumptFormat: o.GofumptFormat,
|
||||
URLRegexp: o.URLRegexp,
|
||||
},
|
||||
|
|
@ -1265,7 +1265,7 @@ func defaultAnalyzers() map[string]*Analyzer {
|
|||
testinggoroutine.Analyzer.Name: {Analyzer: testinggoroutine.Analyzer, Enabled: true},
|
||||
unusedparams.Analyzer.Name: {Analyzer: unusedparams.Analyzer, Enabled: false},
|
||||
unusedwrite.Analyzer.Name: {Analyzer: unusedwrite.Analyzer, Enabled: false},
|
||||
useany.Analyzer.Name: {Analyzer: useany.Analyzer, Enabled: true},
|
||||
useany.Analyzer.Name: {Analyzer: useany.Analyzer, Enabled: false},
|
||||
infertypeargs.Analyzer.Name: {Analyzer: infertypeargs.Analyzer, Enabled: true},
|
||||
|
||||
// gofmt -s suite:
|
||||
|
|
|
|||
Loading…
Reference in New Issue