mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-07-01 07:42:40 +00:00
Add gometalinter (#2627)
Parallel to https://github.com/terraform-providers/terraform-provider-azurerm/pull/2116 We need to run `gofmt -s` to switch over to the `gofmt` rule, and MM is going to complicate that. Once `1.20.0` is done, I'll run that command on flat MM files & add a `gofmt -s` step to MM generation (goimports does gofmt but doesn't do the s flag for silly reasons). I'll duplicate this over to tpgb once this PR is merged.
This commit is contained in:
parent
4ca28df47a
commit
ee48586fb2
15
.gometalinter.json
Normal file
15
.gometalinter.json
Normal file
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"Deadline": "10m",
|
||||
"Enable": [
|
||||
"vet"
|
||||
],
|
||||
"EnableGC": true,
|
||||
"Linters": {
|
||||
},
|
||||
"Sort": [
|
||||
"path",
|
||||
"line"
|
||||
],
|
||||
"Vendor": true,
|
||||
"WarnUnmatchedDirective": true
|
||||
}
|
|
@ -12,12 +12,12 @@ install:
|
|||
# packages that live there.
|
||||
# See: https://github.com/golang/go/issues/12933
|
||||
- bash scripts/gogetcookie.sh
|
||||
- go get github.com/kardianos/govendor
|
||||
- make tools
|
||||
|
||||
script:
|
||||
- make lint
|
||||
- make test
|
||||
- make vendor-status
|
||||
- make vet
|
||||
- make website-test
|
||||
|
||||
branches:
|
||||
|
|
24
GNUmakefile
24
GNUmakefile
|
@ -1,5 +1,4 @@
|
|||
TEST?=$$(go list ./... |grep -v 'vendor')
|
||||
GOFMT_FILES?=$$(find . -name '*.go' |grep -v vendor)
|
||||
WEBSITE_REPO=github.com/hashicorp/terraform-website
|
||||
PKG_NAME=google
|
||||
|
||||
|
@ -16,23 +15,22 @@ test: fmtcheck
|
|||
testacc: fmtcheck
|
||||
TF_ACC=1 TF_SCHEMA_PANIC_ON_ERROR=1 go test $(TEST) -v $(TESTARGS) -timeout 120m -ldflags="-X=github.com/terraform-providers/terraform-provider-google/version.ProviderVersion=acc"
|
||||
|
||||
vet:
|
||||
@echo "go vet ."
|
||||
@go vet $$(go list ./... | grep -v vendor/) ; if [ $$? -eq 1 ]; then \
|
||||
echo ""; \
|
||||
echo "Vet found suspicious constructs. Please check the reported constructs"; \
|
||||
echo "and fix them if necessary before submitting the code for review."; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
fmt:
|
||||
gofmt -w $(GOFMT_FILES)
|
||||
@echo "==> Fixing source code with gofmt..."
|
||||
gofmt -w ./$(PKG_NAME)
|
||||
|
||||
# Currently required by tf-deploy compile
|
||||
fmtcheck:
|
||||
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"
|
||||
|
||||
errcheck:
|
||||
@sh -c "'$(CURDIR)/scripts/errcheck.sh'"
|
||||
lint:
|
||||
@echo "==> Checking source code against linters..."
|
||||
@gometalinter ./$(PKG_NAME)
|
||||
tools:
|
||||
@echo "==> installing required tooling..."
|
||||
go get -u github.com/kardianos/govendor
|
||||
go get -u github.com/alecthomas/gometalinter
|
||||
gometalinter --install
|
||||
|
||||
vendor-status:
|
||||
@govendor status
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Check gofmt
|
||||
echo "==> Checking for unchecked errors..."
|
||||
|
||||
if ! which errcheck > /dev/null; then
|
||||
echo "==> Installing errcheck..."
|
||||
go get -u github.com/kisielk/errcheck
|
||||
fi
|
||||
|
||||
err_files=$(errcheck -ignoretests \
|
||||
-ignore 'github.com/hashicorp/terraform/helper/schema:Set' \
|
||||
-ignore 'bytes:.*' \
|
||||
-ignore 'io:Close|Write' \
|
||||
$(go list ./...| grep -v /vendor/))
|
||||
|
||||
if [[ -n ${err_files} ]]; then
|
||||
echo 'Unchecked errors found in the following places:'
|
||||
echo "${err_files}"
|
||||
echo "Please handle returned errors. You can check directly with \`make errcheck\`"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
Loading…
Reference in New Issue
Block a user