diff --git a/Makefile b/Makefile index eeba4ff5d..1e286588e 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,4 @@ +include scripts/lint.mk include scripts/clients.mk .DEFAULT_GOAL := help @@ -60,36 +61,6 @@ simplecross: $(BUILD_DIR) ## Cross-compile go binaries without using CGO. clean: ## Clean the binary folder. $(RM) -r $(BUILD_DIR) -##@ Lint - -# Add missing and remove unused modules. -.PHONY: tidy -tidy: - go mod tidy - -# Run `go fmt` against code. -.PHONY: fmt -fmt: - go fmt ./... - -# Run `go vet` and `shadow` (which reports shadowed variables) against code. -# https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/shadow -# `go install golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow@latest` -.PHONY: vet -vet: - go vet ./... - shadow ./... - -# Run `golangci-lint` against code. -# `golangci-lint` runs `gofmt`, `govet`, `staticcheck` and other linters. -# https://golangci-lint.run/usage/install/#local-installation -.PHONY: golangci-lint -golangci-lint: - golangci-lint run --fix --timeout 5m - -.PHONY: lint -lint: tidy vet golangci-lint ## Run linters. - ##@ Test .PHONY: test diff --git a/scripts/lint.mk b/scripts/lint.mk new file mode 100644 index 000000000..e34e9ae04 --- /dev/null +++ b/scripts/lint.mk @@ -0,0 +1,29 @@ +##@ Lint + +# Add missing and remove unused modules. +.PHONY: tidy +tidy: + go mod tidy + +# Run `go fmt` against code. +.PHONY: fmt +fmt: + go fmt ./... + +# Run `go vet` and `shadow` (which reports shadowed variables) against code. +# https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/shadow +# `go install golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow@latest` +.PHONY: vet +vet: + go vet ./... + shadow ./... + +# Run `golangci-lint` against code. +# `golangci-lint` runs `gofmt`, `govet`, `staticcheck` and other linters. +# https://golangci-lint.run/usage/install/#local-installation +.PHONY: golangci-lint +golangci-lint: + golangci-lint run --fix --timeout 5m + +.PHONY: lint +lint: tidy vet golangci-lint ## Run linters.