Skip to content

Commit

Permalink
gopls: fix various staticcheck errors
Browse files Browse the repository at this point in the history
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 <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Robert Findley <rfindley@google.com>
  • Loading branch information
findleyr committed Sep 29, 2020
1 parent ffa3839 commit 5272f30
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 26 deletions.
4 changes: 0 additions & 4 deletions gopls/internal/regtest/modfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,6 @@ package main
func main() {
fmt.Println(blah.Name)
`
const want = `module mod.com
go 1.12
`
runner.Run(t, mod, func(t *testing.T, env *Env) {
env.Await(env.DiagnosticAtRegexp("go.mod", "require"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import (
"go/printer"
"go/token"
"reflect"
"unicode"
"unicode/utf8"

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

func isWildcard(s string) bool {
rune, size := utf8.DecodeRuneInString(s)
return size == len(s) && unicode.IsLower(rune)
}

// Values/types for special cases.
var (
identType = reflect.TypeOf((*ast.Ident)(nil))
objectPtrType = reflect.TypeOf((*ast.Object)(nil))
positionType = reflect.TypeOf(token.NoPos)
callExprType = reflect.TypeOf((*ast.CallExpr)(nil))
scopePtrType = reflect.TypeOf((*ast.Scope)(nil))
)
2 changes: 1 addition & 1 deletion internal/lsp/cache/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ func typeCheck(ctx context.Context, snapshot *snapshot, m *metadata, mode source
if found {
return pkg, nil
}
return nil, errors.Errorf("no parsed files for package %s, expected: %s, list errors: %v", pkg.m.pkgPath, pkg.compiledGoFiles, rawErrors)
return nil, errors.Errorf("no parsed files for package %s, expected: %v, list errors: %v", pkg.m.pkgPath, pkg.compiledGoFiles, rawErrors)
} else {
pkg.types = types.NewPackage(string(m.pkgPath), string(m.name))
}
Expand Down
8 changes: 0 additions & 8 deletions internal/lsp/cache/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,14 +512,6 @@ func (s *Session) DidModifyFiles(ctx context.Context, changes []source.FileModif
return snapshots, releases, deletionsSlice, nil
}

func (s *Session) isOpen(uri span.URI) bool {
s.overlayMu.Lock()
defer s.overlayMu.Unlock()

_, open := s.overlays[uri]
return open
}

func (s *Session) updateOverlays(ctx context.Context, changes []source.FileModification) (map[span.URI]*overlay, error) {
s.overlayMu.Lock()
defer s.overlayMu.Unlock()
Expand Down
2 changes: 0 additions & 2 deletions internal/lsp/cmd/test/cmdtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"sync"
"testing"

"golang.org/x/tools/go/packages/packagestest"
"golang.org/x/tools/internal/jsonrpc2/servertest"
"golang.org/x/tools/internal/lsp/cache"
"golang.org/x/tools/internal/lsp/cmd"
Expand All @@ -31,7 +30,6 @@ import (
)

type runner struct {
exporter packagestest.Exporter
data *tests.Data
ctx context.Context
options func(*source.Options)
Expand Down
3 changes: 0 additions & 3 deletions internal/lsp/source/workspace_symbol.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,6 @@ func bestMatch(fullPath string, matcher matcherFunc) (string, float64) {
// * A symbolizer determines how we extract the symbol for an object. This
// enables the 'symbolStyle' configuration option.
type symbolCollector struct {
// query is the user-supplied query passed to the Symbol method.
query string

// These types parameterize the symbol-matching pass.
matcher matcherFunc
symbolizer symbolizer
Expand Down

0 comments on commit 5272f30

Please sign in to comment.