Skip to content

Commit

Permalink
Add gometalinter (#2627)
Browse files Browse the repository at this point in the history
Parallel to hashicorp/terraform-provider-azurerm#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.
  • Loading branch information
rileykarson authored and nat-henderson committed Dec 21, 2018
1 parent 11044db commit 3d4fa23
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 39 deletions.
15 changes: 15 additions & 0 deletions .gometalinter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"Deadline": "10m",
"Enable": [
"vet"
],
"EnableGC": true,
"Linters": {
},
"Sort": [
"path",
"line"
],
"Vendor": true,
"WarnUnmatchedDirective": true
}
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
24 changes: 11 additions & 13 deletions GNUmakefile
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand Down
24 changes: 0 additions & 24 deletions scripts/errcheck.sh

This file was deleted.

0 comments on commit 3d4fa23

Please sign in to comment.