From c1d9a1e1748bdea675c975ff753b25a057ba8d8e Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Fri, 11 Jan 2019 16:29:49 +0000 Subject: [PATCH] build: use golangci-lint for code quality checks --- .golangci.yml | 27 +++++++++++++++++++++++++++ .gometalinter.json | 14 -------------- Makefile | 24 +++++++----------------- 3 files changed, 34 insertions(+), 31 deletions(-) create mode 100644 .golangci.yml delete mode 100644 .gometalinter.json diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 000000000..d30a4900c --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,27 @@ +# golangci-lint configuration options + +run: + build-tags: + - cmount + +linters: + enable: + - deadcode + - errcheck + - goimports + - golint + - ineffassign + - structcheck + - varcheck + - govet + - unconvert + #- prealloc + #- maligned + disable-all: true + +issues: + # Maximum issues count per one linter. Set to 0 to disable. Default is 50. + max-per-linter: 0 + + # Maximum count of issues with the same text. Set to 0 to disable. Default is 3. + max-same-issues: 0 diff --git a/.gometalinter.json b/.gometalinter.json deleted file mode 100644 index 4cd25d5ba..000000000 --- a/.gometalinter.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "Enable": [ - "deadcode", - "errcheck", - "goimports", - "golint", - "ineffassign", - "structcheck", - "varcheck", - "vet" - ], - "EnableGC": true, - "Vendor": true -} diff --git a/Makefile b/Makefile index cbc0fa0d6..b3e29ae30 100644 --- a/Makefile +++ b/Makefile @@ -64,30 +64,20 @@ endif # Do source code quality checks check: rclone ifdef FULL_TESTS - go vet $(BUILDTAGS) -printfuncs Debugf,Infof,Logf,Errorf ./... - errcheck $(BUILDTAGS) ./... - find . -name \*.go | grep -v /vendor/ | xargs goimports -d | grep . ; test $$? -eq 1 - go list ./... | xargs -n1 golint | grep -E -v '(StorageUrl|CdnUrl|ApplicationCredentialId)' ; test $$? -eq 1 + @# we still run go vet for -printfuncs which golangci-lint doesn't do yet + @# see: https://github.com/golangci/golangci-lint/issues/204 + @echo "-- START CODE QUALITY REPORT -------------------------------" + @go vet $(BUILDTAGS) -printfuncs Debugf,Infof,Logf,Errorf ./... + @golangci-lint run ./... + @echo "-- END CODE QUALITY REPORT ---------------------------------" else @echo Skipping source quality tests as version of go too old endif -gometalinter_install: - go get -u github.com/alecthomas/gometalinter - gometalinter --install --update - -# We aren't using gometalinter as the default linter yet because -# 1. it doesn't support build tags: https://github.com/alecthomas/gometalinter/issues/275 -# 2. can't get -printfuncs working with the vet linter -gometalinter: - gometalinter ./... - # Get the build dependencies build_dep: ifdef FULL_TESTS - go get -u github.com/kisielk/errcheck - go get -u golang.org/x/tools/cmd/goimports - go get -u golang.org/x/lint/golint + go run bin/get-github-release.go -extract golangci-lint golangci/golangci-lint 'golangci-lint-.*-linux-amd64.tar.gz' endif # Get the release dependencies