2019-06-12 20:04:42 -06:00
|
|
|
// Copyright 2019 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package hooks
|
|
|
|
|
|
|
|
import (
|
|
|
|
"golang.org/x/tools/internal/lsp/source"
|
|
|
|
"honnef.co/go/tools/simple"
|
|
|
|
"honnef.co/go/tools/staticcheck"
|
|
|
|
"honnef.co/go/tools/stylecheck"
|
|
|
|
)
|
|
|
|
|
2019-10-10 18:48:16 -06:00
|
|
|
func updateAnalyzers(options *source.Options) {
|
|
|
|
if options.StaticCheck {
|
2019-06-12 20:04:42 -06:00
|
|
|
for _, a := range simple.Analyzers {
|
2020-03-10 08:14:56 -06:00
|
|
|
options.DefaultAnalyzers[a.Name] = source.Analyzer{Analyzer: a, Enabled: true}
|
2019-06-12 20:04:42 -06:00
|
|
|
}
|
|
|
|
for _, a := range staticcheck.Analyzers {
|
2020-01-16 16:34:52 -07:00
|
|
|
// This check conflicts with the vet printf check (golang/go#34494).
|
|
|
|
if a.Name == "SA5009" {
|
|
|
|
continue
|
|
|
|
}
|
2020-03-10 08:14:56 -06:00
|
|
|
options.DefaultAnalyzers[a.Name] = source.Analyzer{Analyzer: a, Enabled: true}
|
2019-06-12 20:04:42 -06:00
|
|
|
}
|
|
|
|
for _, a := range stylecheck.Analyzers {
|
2020-03-10 08:14:56 -06:00
|
|
|
options.DefaultAnalyzers[a.Name] = source.Analyzer{Analyzer: a, Enabled: true}
|
2019-06-12 20:04:42 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|