Skip to content

Commit 5272f30

Browse files
committed
gopls: fix various staticcheck errors
Do a pass of unused code cleanup and other staticcheck errors. Change-Id: Iaf5d27c4f5405d4cce3e48fa06a5d46ec757de40 Reviewed-on: https://go-review.googlesource.com/c/tools/+/257965 Run-TryBot: Robert Findley <[email protected]> gopls-CI: kokoro <[email protected]> Reviewed-by: Rebecca Stambler <[email protected]> TryBot-Result: Go Bot <[email protected]> Trust: Robert Findley <[email protected]>
1 parent ffa3839 commit 5272f30

File tree

6 files changed

+1
-26
lines changed

6 files changed

+1
-26
lines changed

gopls/internal/regtest/modfile_test.go

-4
Original file line numberDiff line numberDiff line change
@@ -311,10 +311,6 @@ package main
311311
312312
func main() {
313313
fmt.Println(blah.Name)
314-
`
315-
const want = `module mod.com
316-
317-
go 1.12
318314
`
319315
runner.Run(t, mod, func(t *testing.T, env *Env) {
320316
env.Await(env.DiagnosticAtRegexp("go.mod", "require"))

internal/lsp/analysis/simplifycompositelit/simplifycompositelit.go

-8
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ import (
1414
"go/printer"
1515
"go/token"
1616
"reflect"
17-
"unicode"
18-
"unicode/utf8"
1917

2018
"golang.org/x/tools/go/analysis"
2119
"golang.org/x/tools/go/analysis/passes/inspect"
@@ -189,16 +187,10 @@ func match(pattern, val reflect.Value) bool {
189187
return p.Interface() == v.Interface()
190188
}
191189

192-
func isWildcard(s string) bool {
193-
rune, size := utf8.DecodeRuneInString(s)
194-
return size == len(s) && unicode.IsLower(rune)
195-
}
196-
197190
// Values/types for special cases.
198191
var (
199192
identType = reflect.TypeOf((*ast.Ident)(nil))
200193
objectPtrType = reflect.TypeOf((*ast.Object)(nil))
201194
positionType = reflect.TypeOf(token.NoPos)
202195
callExprType = reflect.TypeOf((*ast.CallExpr)(nil))
203-
scopePtrType = reflect.TypeOf((*ast.Scope)(nil))
204196
)

internal/lsp/cache/check.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ func typeCheck(ctx context.Context, snapshot *snapshot, m *metadata, mode source
366366
if found {
367367
return pkg, nil
368368
}
369-
return nil, errors.Errorf("no parsed files for package %s, expected: %s, list errors: %v", pkg.m.pkgPath, pkg.compiledGoFiles, rawErrors)
369+
return nil, errors.Errorf("no parsed files for package %s, expected: %v, list errors: %v", pkg.m.pkgPath, pkg.compiledGoFiles, rawErrors)
370370
} else {
371371
pkg.types = types.NewPackage(string(m.pkgPath), string(m.name))
372372
}

internal/lsp/cache/session.go

-8
Original file line numberDiff line numberDiff line change
@@ -512,14 +512,6 @@ func (s *Session) DidModifyFiles(ctx context.Context, changes []source.FileModif
512512
return snapshots, releases, deletionsSlice, nil
513513
}
514514

515-
func (s *Session) isOpen(uri span.URI) bool {
516-
s.overlayMu.Lock()
517-
defer s.overlayMu.Unlock()
518-
519-
_, open := s.overlays[uri]
520-
return open
521-
}
522-
523515
func (s *Session) updateOverlays(ctx context.Context, changes []source.FileModification) (map[span.URI]*overlay, error) {
524516
s.overlayMu.Lock()
525517
defer s.overlayMu.Unlock()

internal/lsp/cmd/test/cmdtest.go

-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
"sync"
1818
"testing"
1919

20-
"golang.org/x/tools/go/packages/packagestest"
2120
"golang.org/x/tools/internal/jsonrpc2/servertest"
2221
"golang.org/x/tools/internal/lsp/cache"
2322
"golang.org/x/tools/internal/lsp/cmd"
@@ -31,7 +30,6 @@ import (
3130
)
3231

3332
type runner struct {
34-
exporter packagestest.Exporter
3533
data *tests.Data
3634
ctx context.Context
3735
options func(*source.Options)

internal/lsp/source/workspace_symbol.go

-3
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,6 @@ func bestMatch(fullPath string, matcher matcherFunc) (string, float64) {
140140
// * A symbolizer determines how we extract the symbol for an object. This
141141
// enables the 'symbolStyle' configuration option.
142142
type symbolCollector struct {
143-
// query is the user-supplied query passed to the Symbol method.
144-
query string
145-
146143
// These types parameterize the symbol-matching pass.
147144
matcher matcherFunc
148145
symbolizer symbolizer

0 commit comments

Comments
 (0)