Update gometalinter for modules, add staticcheck (#2908)
This isn't working locally, but it matches the changes made in https://github.com/terraform-providers/terraform-provider-azurerm/pull/2722 so maybe something freaky is going on and it will only work in CI? Edit: This only works in CI (well, at least doesn't work locally for *me*) but the same is true in the Azure provider. Most of those rules can be turned back on provided we make the corresponding code changes, but let's bring back `unused` for now. I'll dupe over to tpgb on approval.
This commit is contained in:
parent
222c287629
commit
8a237de2dd
|
@ -3,6 +3,7 @@
|
|||
"Enable": [
|
||||
"gofmt",
|
||||
"misspell",
|
||||
"staticcheck",
|
||||
"structcheck",
|
||||
"unconvert",
|
||||
"varcheck",
|
||||
|
|
|
@ -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
|
||||
|
|
13
GNUmakefile
13
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
|
||||
|
||||
|
|
|
@ -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 + `\(\)`)
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
checks = [
|
||||
"all",
|
||||
"-S1002",
|
||||
"-S1007",
|
||||
"-S1008",
|
||||
"-S1009",
|
||||
"-S1019",
|
||||
"-S1021",
|
||||
"-S1025",
|
||||
"-S1034",
|
||||
"-ST1000",
|
||||
"-ST1003",
|
||||
"-ST1005",
|
||||
"-ST1017",
|
||||
"-SA4006",
|
||||
"-SA4010",
|
||||
"-SA6000",
|
||||
"-SA6005"
|
||||
]
|
Loading…
Reference in New Issue