From 332987a829c3275fbfaf9afc93f78891e6650632 Mon Sep 17 00:00:00 2001 From: Dominik Honnef Date: Tue, 14 Apr 2020 05:03:49 +0200 Subject: [PATCH] gopls/internal/hooks: don't run staticcheck's SA5011 SA5011 relies on facts from dependencies to avoid false positives. However, gopls currently only loads export data for dependencies, it does not compute facts. SA5011 is unlike other analyzers in staticcheck, which may produce false negatives if facts are missing, but no false positives. Change-Id: I5063b701bbedca7b09d1894997f8c574fa497939 Reviewed-on: https://go-review.googlesource.com/c/tools/+/228119 Run-TryBot: Dominik Honnef Reviewed-by: Rebecca Stambler TryBot-Result: Gobot Gobot --- gopls/internal/hooks/analysis.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gopls/internal/hooks/analysis.go b/gopls/internal/hooks/analysis.go index 3a4c00fd93..f46a93f446 100644 --- a/gopls/internal/hooks/analysis.go +++ b/gopls/internal/hooks/analysis.go @@ -17,11 +17,15 @@ func updateAnalyzers(options *source.Options) { options.AddDefaultAnalyzer(a) } for _, a := range staticcheck.Analyzers { - // This check conflicts with the vet printf check (golang/go#34494). - if a.Name == "SA5009" { - continue + switch a.Name { + case "SA5009": + // This check conflicts with the vet printf check (golang/go#34494). + case "SA5011": + // This check relies on facts from dependencies, which + // we don't currently compute. + default: + options.AddDefaultAnalyzer(a) } - options.AddDefaultAnalyzer(a) } for _, a := range stylecheck.Analyzers { options.AddDefaultAnalyzer(a)