Skip to content

Commit

Permalink
lint: switch to new staticcheck
Browse files Browse the repository at this point in the history
Replace the TestMegacheck and TestUnused tests with a call to the new
`staticcheck`.

Our custom checkers will need to be rewritten using the new
interfaces; disable the old code until then (this will be tracked
by cockroachdb#33669).

Fixes cockroachdb#37061.

Release note: None
  • Loading branch information
RaduBerinde committed May 12, 2019
1 parent 88b396f commit 689d777
Show file tree
Hide file tree
Showing 14 changed files with 90 additions and 207 deletions.
41 changes: 29 additions & 12 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ required = [
"golang.org/x/tools/cmd/goyacc",
"golang.org/x/tools/cmd/stringer",
"golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow",
"honnef.co/go/tools/cmd/staticcheck",
]

ignored = [
Expand Down Expand Up @@ -98,7 +99,9 @@ ignored = [
# Pin to 2017.2.2 because of https://github.com/cockroachdb/cockroach/issues/33669.
[[constraint]]
name = "honnef.co/go/tools"
version = "=2017.2.2"
# This revision is not yet on master (as of 05-12-2019); when it is, we can
# switch to just using the master branch.
revision = "4187a5ff696fcfe80ef2204f78a3ae8262b2d54d"

# Test util - don't need to pin.
[[constraint]]
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,8 @@ bin/.bootstrap: $(GITHOOKS) Gopkg.lock | bin/.submodules-initialized
./vendor/golang.org/x/perf/cmd/benchstat \
./vendor/golang.org/x/tools/cmd/goyacc \
./vendor/golang.org/x/tools/cmd/stringer \
./vendor/golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow
./vendor/golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow \
./vendor/honnef.co/go/tools/cmd/staticcheck
touch $@

.SECONDARY: bin/.submodules-initialized
Expand Down
3 changes: 3 additions & 0 deletions pkg/cli/flags_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@ import (
humanize "github.com/dustin/go-humanize"
"github.com/elastic/gosigar"
"github.com/pkg/errors"
"github.com/spf13/pflag"
)

type localityList []roachpb.LocalityAddress

var _ pflag.Value = &localityList{}

// Type implements the pflag.Value interface.
func (l *localityList) Type() string { return "localityList" }

Expand Down
2 changes: 2 additions & 0 deletions pkg/roachpb/span_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ func (g *SpanGroup) Len() int {
return g.rg.Len()
}

var _ = (*SpanGroup).Len

// Slice will return the contents of the SpanGroup as a slice of Spans.
func (g *SpanGroup) Slice() []Span {
rg := g.rg
Expand Down
2 changes: 2 additions & 0 deletions pkg/storage/engine/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ func (b *RocksDBBatchBuilder) Len() int {
return len(b.repr)
}

var _ = (*RocksDBBatchBuilder).Len

// getRepr constructs the batch representation and returns it.
func (b *RocksDBBatchBuilder) getRepr() []byte {
b.maybeInit()
Expand Down
3 changes: 2 additions & 1 deletion pkg/testutils/lint/checker_float.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
// implied. See the License for the specific language governing
// permissions and limitations under the License.

// +build lint
// TODO(radu): re-enable the checkers using the new staticcheck interfaces.
// +build lint_todo

package lint

Expand Down
3 changes: 2 additions & 1 deletion pkg/testutils/lint/checker_hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
// implied. See the License for the specific language governing
// permissions and limitations under the License.

// +build lint
// TODO(radu): re-enable the checkers using the new staticcheck interfaces.
// +build lint_todo

package lint

Expand Down
3 changes: 2 additions & 1 deletion pkg/testutils/lint/checker_misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
// implied. See the License for the specific language governing
// permissions and limitations under the License.

// +build lint
// TODO(radu): re-enable the checkers using the new staticcheck interfaces.
// +build lint_todo

package lint

Expand Down
3 changes: 2 additions & 1 deletion pkg/testutils/lint/checker_timer.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
// implied. See the License for the specific language governing
// permissions and limitations under the License.

// +build lint
// TODO(radu): re-enable the checkers using the new staticcheck interfaces.
// +build lint_todo

package lint

Expand Down
3 changes: 2 additions & 1 deletion pkg/testutils/lint/checker_unconvert.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
// implied. See the License for the specific language governing
// permissions and limitations under the License.

// +build lint
// TODO(radu): re-enable the checkers using the new staticcheck interfaces.
// +build lint_todo

package lint

Expand Down
Loading

0 comments on commit 689d777

Please sign in to comment.