internal/lsp: fix two more staticcheck warnings

Found by running:

  $ staticcheck --checks all ./internal/lsp/...

And then manually checking the results.

Change-Id: I6a0abf72596de6539c19bb0244860c5bd0ac8fd1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/258917
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Trust: Rebecca Stambler <rstambler@golang.org>
Trust: Heschi Kreinick <heschi@google.com>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
Ainar Garipov 2020-10-01 23:23:22 +03:00 committed by Rebecca Stambler
parent af0a1b5f3c
commit dc8b4bacda
2 changed files with 5 additions and 6 deletions

View File

@ -182,10 +182,9 @@ func (r *runner) Diagnostics(t *testing.T, uri span.URI, want []*source.Diagnost
// Get the diagnostics for this view if we have not done it before.
v := r.server.session.View(r.data.Config.Dir)
r.collectDiagnostics(v)
var got []*source.Diagnostic
for _, d := range r.diagnostics[uri] {
got = append(got, d)
}
d := r.diagnostics[uri]
got := make([]*source.Diagnostic, len(d))
copy(got, d)
// A special case to test that there are no diagnostics for a file.
if len(want) == 1 && want[0].Source == "no_diagnostics" {
if len(got) != 0 {

View File

@ -510,8 +510,8 @@ func (o *Options) Clone() *Options {
return result
}
func (options *Options) AddStaticcheckAnalyzer(a *analysis.Analyzer) {
options.StaticcheckAnalyzers[a.Name] = Analyzer{Analyzer: a, Enabled: true}
func (o *Options) AddStaticcheckAnalyzer(a *analysis.Analyzer) {
o.StaticcheckAnalyzers[a.Name] = Analyzer{Analyzer: a, Enabled: true}
}
func (o *Options) set(name string, value interface{}) OptionResult {