makefile: switched to golangci-lint

This commit is contained in:
Michał Matczuk
2018-07-28 06:41:33 +02:00
parent a9f91f5f4b
commit 47c22c9fd2
2 changed files with 28 additions and 25 deletions

View File

@@ -1,35 +1,44 @@
all: check test bench
ifndef GOBIN
export GOBIN := $(GOPATH)/bin
endif
.PHONY: fmt
fmt: ## Format source code
@go fmt ./...
.PHONY: check
check: .check-fmt .check-vet .check-lint .check-ineffassign .check-mega .check-misspell
check: ## Perform static code analysis
check: .check-misspell .check-lint
.PHONY: .check-fmt
.check-fmt:
@go fmt ./... | tee /dev/stderr | ifne false
.PHONY: .check-vet
.check-vet:
@go vet ./...
.PHONY: .check-misspell
.check-misspell:
@$(GOBIN)/misspell ./...
.PHONY: .check-lint
.check-lint:
@golint -set_exit_status ./...
.PHONY: .check-ineffassign
.check-ineffassign:
@ineffassign .
.PHONY: .check-mega
.check-mega:
@megacheck ./...
.PHONY: .check-misspell
.check-misspell:
@misspell ./...
@$(GOBIN)/golangci-lint run -s --disable-all -E govet -E errcheck -E staticcheck \
-E gas -E typecheck -E unused -E structcheck -E varcheck -E ineffassign -E deadcode \
-E gofmt -E golint -E gosimple -E unconvert -E dupl -E depguard -E gocyclo \
--tests=false \
--exclude-use-default=false \
--exclude='composite literal uses unkeyed fields' \
--exclude='Error return value of `.+\.Close` is not checked' \
--exclude='G104' \
--exclude='G304' \
--exclude='G401' \
--exclude='G501' \
./...
GOTEST := go test -cover -race -tags all
.PHONY: test
test: ## Run unit and integration tests
test:
@$(GOTEST) .
@$(GOTEST) ./migrate
@@ -44,19 +53,13 @@ bench:
get-deps:
go get -t ./...
ifndef GOBIN
export GOBIN := $(GOPATH)/bin
endif
.PHONY: get-tools
get-tools: GOPATH := $(shell mktemp -d)
get-tools:
@echo "==> Installing tools at $(GOBIN)..."
@mkdir -p $(GOBIN)
@go get -u github.com/golang/lint/golint
@go get -u github.com/client9/misspell/cmd/misspell
@go get -u github.com/gordonklaus/ineffassign
@go get -u honnef.co/go/tools/cmd/megacheck
@go get -u github.com/golangci/golangci-lint/cmd/golangci-lint
@rm -Rf $(GOPATH)