Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

build: use golangci-lint for code quality checks

Nick Craig-Woodc1d9a1e1748b
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