From 0d2542f8f299ec1d02bf495b48807adca7f4ad27 Mon Sep 17 00:00:00 2001 From: Riley Karson Date: Tue, 22 Jan 2019 11:35:00 -0800 Subject: [PATCH 1/2] Update gometalinter to add staticcheck, properly handle modules. --- .gometalinter.json | 1 + GNUmakefile | 13 +++++++------ scripts/affectedtests/affectedtests.go | 4 ++-- staticcheck.conf | 19 +++++++++++++++++++ 4 files changed, 29 insertions(+), 8 deletions(-) create mode 100644 staticcheck.conf diff --git a/.gometalinter.json b/.gometalinter.json index 90ac0015e90..f19055ec59e 100644 --- a/.gometalinter.json +++ b/.gometalinter.json @@ -3,6 +3,7 @@ "Enable": [ "gofmt", "misspell", + "staticcheck", "structcheck", "unconvert", "varcheck", diff --git a/GNUmakefile b/GNUmakefile index 3b402f8c9e2..a81faea8e34 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -21,16 +21,17 @@ fmt: # Currently required by tf-deploy compile fmtcheck: + @echo "==> Checking source code against gofmt..." @sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'" lint: @echo "==> Checking source code against linters..." - @gometalinter ./$(PKG_NAME) - tools: + @bash -c "GO111MODULE=off gometalinter -d ./... 2> >(egrep '(^DEBUG.*linter took|^DEBUG.*total elapsed|^[^D])' >&2)" + +tools: @echo "==> installing required tooling..." - go get -u github.com/kardianos/govendor - go get -u github.com/alecthomas/gometalinter - gometalinter --install + GO111MODULE=off go get -u github.com/alecthomas/gometalinter + GO111MODULE=off gometalinter --install test-compile: @if [ "$(TEST)" = "./..." ]; then \ @@ -54,5 +55,5 @@ ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO))) endif @$(MAKE) -C $(GOPATH)/src/$(WEBSITE_REPO) website-provider-test PROVIDER_PATH=$(shell pwd) PROVIDER_NAME=$(PKG_NAME) -.PHONY: build test testacc vet fmt fmtcheck errcheck test-compile website website-test +.PHONY: build test testacc vet fmt fmtcheck lint tools errcheck test-compile website website-test diff --git a/scripts/affectedtests/affectedtests.go b/scripts/affectedtests/affectedtests.go index a6c5b838457..b79be76acc8 100644 --- a/scripts/affectedtests/affectedtests.go +++ b/scripts/affectedtests/affectedtests.go @@ -91,7 +91,7 @@ func main() { } } testnames := []string{} - for tn, _ := range tests { + for tn := range tests { testnames = append(testnames, tn) } sort.Strings(testnames) @@ -153,7 +153,7 @@ func getResourceName(fName, googleDir string, providerFiles []string) (string, e } // Loop through all the top-level objects in the resource file. // One of them is the resource definition: something like resourceComputeInstance() - for k, _ := range resourceFile.Scope.Objects { + for k := range resourceFile.Scope.Objects { // Matches the line in the provider file where the resource is defined, // e.g. "google_compute_instance": resourceComputeInstance() re := regexp.MustCompile(`"(.*)":\s*` + k + `\(\)`) diff --git a/staticcheck.conf b/staticcheck.conf new file mode 100644 index 00000000000..7ac3b88289e --- /dev/null +++ b/staticcheck.conf @@ -0,0 +1,19 @@ +checks = [ + "all", + "-S1002", + "-S1007", + "-S1008", + "-S1009", + "-S1019", + "-S1021", + "-S1025", + "-S1034", + "-ST1000", + "-ST1003", + "-ST1005", + "-ST1017", + "-SA4006", + "-SA4010", + "-SA6000", + "-SA6005" +] From 730d44a5ff0859faf1a76b514a713cdb66ce2d81 Mon Sep 17 00:00:00 2001 From: Riley Karson Date: Mon, 4 Feb 2019 08:48:38 -0800 Subject: [PATCH 2/2] Update travis --- .travis.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3a764592c17..8c29147b5f7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,8 @@ services: language: go go: - "1.11.x" +env: + - GO111MODULE=off install: # This script is used by the Travis build to install a cookie for @@ -19,9 +21,6 @@ script: - make test - make website-test -env: - - GO111MODULE=off - branches: only: - master