Skip to content

Commit

Permalink
internal/settings: simplify linking now that we only build with 1.23
Browse files Browse the repository at this point in the history
Since gopls now only builds with the latest version of Go, we no longer
need special linking to align with the compatibility windows of gufumpt
or staticcheck.

Updates golang/go#65917

Change-Id: I7d5ebe6807b34ed8d44e726c7a6585d4c7c7e696
Reviewed-on: https://go-review.googlesource.com/c/tools/+/612055
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Findley <rfindley@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
  • Loading branch information
findleyr authored and gopherbot committed Sep 9, 2024
1 parent c055e89 commit 1dc949f
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 68 deletions.
4 changes: 0 additions & 4 deletions gopls/internal/settings/analysis.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,3 @@ func init() {
DefaultAnalyzers[analyzer.analyzer.Name] = analyzer
}
}

// StaticcheckAnalzyers describes available Staticcheck analyzers, keyed by
// analyzer name.
var StaticcheckAnalyzers = make(map[string]*Analyzer) // written by analysis_<ver>.go
10 changes: 0 additions & 10 deletions gopls/internal/settings/analysis_119.go

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build go1.20
// +build go1.20

package settings

import (
Expand All @@ -14,8 +11,6 @@ import (
"mvdan.cc/gofumpt/format"
)

const GofumptSupported = true

// GofumptFormat allows the gopls module to wire in a call to
// gofumpt/format.Source. langVersion and modulePath are used for some
// Gofumpt formatting rules -- see the Gofumpt documentation for details.
Expand Down
14 changes: 0 additions & 14 deletions gopls/internal/settings/gofumpt_119.go

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build go1.20
// +build go1.20

package settings

import "testing"
Expand Down
21 changes: 2 additions & 19 deletions gopls/internal/settings/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"fmt"
"maps"
"path/filepath"
"runtime"
"strings"
"time"

Expand Down Expand Up @@ -1073,15 +1072,7 @@ func (o *Options) setOne(name string, value any) error {
}

case "staticcheck":
v, err := asBool(value)
if err != nil {
return err
}
if v && !StaticcheckSupported {
return fmt.Errorf("staticcheck is not supported at %s;"+
" rebuild gopls with a more recent version of Go", runtime.Version())
}
o.Staticcheck = v
return setBool(&o.Staticcheck, value)

case "local":
return setString(&o.Local, value)
Expand All @@ -1096,15 +1087,7 @@ func (o *Options) setOne(name string, value any) error {
return setBool(&o.ShowBugReports, value)

case "gofumpt":
v, err := asBool(value)
if err != nil {
return err
}
if v && !GofumptSupported {
return fmt.Errorf("gofumpt is not supported at %s;"+
" rebuild gopls with a more recent version of Go", runtime.Version())
}
o.Gofumpt = v
return setBool(&o.Gofumpt, value)

case "completeFunctionCalls":
return setBool(&o.CompleteFunctionCalls, value)
Expand Down
9 changes: 0 additions & 9 deletions gopls/internal/settings/settings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,6 @@ func TestOptions_Set(t *testing.T) {
},
}

if !StaticcheckSupported {
tests = append(tests, testCase{
name: "staticcheck",
value: true,
check: func(o Options) bool { return o.Staticcheck == true },
wantError: true, // o.StaticcheckSupported is unset
})
}

for _, test := range tests {
var opts Options
err := opts.Set(map[string]any{test.name: test.value})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build go1.20
// +build go1.20

package settings

import (
Expand All @@ -16,7 +13,9 @@ import (
"honnef.co/go/tools/stylecheck"
)

const StaticcheckSupported = true
// StaticcheckAnalzyers describes available Staticcheck analyzers, keyed by
// analyzer name.
var StaticcheckAnalyzers = make(map[string]*Analyzer) // written by analysis_<ver>.go

func init() {
mapSeverity := func(severity lint.Severity) protocol.DiagnosticSeverity {
Expand Down

0 comments on commit 1dc949f

Please sign in to comment.