Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update gometalinter for modules, add staticcheck #2908

Merged
merged 2 commits into from Feb 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gometalinter.json
Expand Up @@ -3,6 +3,7 @@
"Enable": [
"gofmt",
"misspell",
"staticcheck",
"structcheck",
"unconvert",
"varcheck",
Expand Down
5 changes: 2 additions & 3 deletions .travis.yml
Expand Up @@ -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
Expand All @@ -19,9 +21,6 @@ script:
- make test
- make website-test

env:
- GO111MODULE=off

branches:
only:
- master
Expand Down
13 changes: 7 additions & 6 deletions GNUmakefile
Expand Up @@ -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 \
Expand All @@ -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

4 changes: 2 additions & 2 deletions scripts/affectedtests/affectedtests.go
Expand Up @@ -91,7 +91,7 @@ func main() {
}
}
testnames := []string{}
for tn, _ := range tests {
for tn := range tests {
testnames = append(testnames, tn)
}
sort.Strings(testnames)
Expand Down Expand Up @@ -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 + `\(\)`)
Expand Down
19 changes: 19 additions & 0 deletions staticcheck.conf
@@ -0,0 +1,19 @@
checks = [
"all",
"-S1002",
"-S1007",
"-S1008",
"-S1009",
"-S1019",
"-S1021",
"-S1025",
"-S1034",
"-ST1000",
"-ST1003",
"-ST1005",
"-ST1017",
"-SA4006",
"-SA4010",
"-SA6000",
"-SA6005"
]