-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Instead of hand-managing and running linters, use golangci-lint. Along with the golangci-lint defaults, enable a couple other linters we generally agree with. See also uber-go/zap#1323 for a similar change. As a result of this, we can: - Drop the dependabot for tools - Run the lint job in parallel with build/test - Simplify the Makefile
- Loading branch information
Showing
9 changed files
with
78 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
output: | ||
# Make output more digestible with quickfix in vim/emacs/etc. | ||
sort-results: true | ||
print-issued-lines: false | ||
|
||
linters: | ||
enable: | ||
- gofumpt | ||
- nolintlint | ||
- revive | ||
|
||
linters-settings: | ||
govet: | ||
# These govet checks are disabled by default, but they're useful. | ||
enable: | ||
- niliness | ||
- reflectvaluecompare | ||
- sortslice | ||
- unusedwrite | ||
|
||
issues: | ||
# Print all issues reported by all linters. | ||
max-issues-per-linter: 0 | ||
max-same-issues: 0 | ||
|
||
# Don't ignore some of the issues that golangci-lint considers okay. | ||
# This includes documenting all exported entities. | ||
exclude-use-default: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,47 @@ | ||
export GOBIN = $(shell pwd)/bin | ||
# Directory containing the Makefile. | ||
PROJECT_ROOT = $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) | ||
|
||
export GOBIN = $(PROJECT_ROOT)/bin | ||
export PATH := $(GOBIN):$(PATH) | ||
|
||
GO_FILES = $(shell find . \ | ||
-path '*/.*' -prune -o \ | ||
'(' -type f -a -name '*.go' ')' -print) | ||
|
||
REVIVE = bin/revive | ||
STATICCHECK = bin/staticcheck | ||
TOOLS = $(REVIVE) $(STATICCHECK) | ||
|
||
TEST_FLAGS ?= -race | ||
|
||
.PHONY: all | ||
all: lint install test | ||
all: lint build test | ||
|
||
.PHONY: lint | ||
lint: gofmt revive staticcheck | ||
|
||
.PHONY: gofmt | ||
gofmt: | ||
$(eval FMT_LOG := $(shell mktemp -t gofmt.XXXXX)) | ||
@gofmt -e -s -l $(GO_FILES) > $(FMT_LOG) || true | ||
@[ ! -s "$(FMT_LOG)" ] || \ | ||
(echo "gofmt failed. Please reformat the following files:" | \ | ||
cat - $(FMT_LOG) && false) | ||
|
||
.PHONY: staticcheck | ||
staticcheck: $(STATICCHECK) | ||
$(STATICCHECK) ./... | ||
|
||
$(STATICCHECK): tools/go.mod | ||
cd tools && go install honnef.co/go/tools/cmd/staticcheck | ||
|
||
.PHONY: revive | ||
revive: $(REVIVE) | ||
$(REVIVE) -set_exit_status ./... | ||
lint: golangci-lint tidy-lint | ||
|
||
$(REVIVE): tools/go.mod | ||
cd tools && go install github.com/mgechev/revive | ||
|
||
.PHONY: install | ||
install: | ||
.PHONY: build | ||
build: | ||
go install . | ||
|
||
.PHONY: test | ||
test: | ||
go test $(TEST_FLAGS) ./... | ||
|
||
.PHONY: build | ||
run: build | ||
sally | ||
|
||
.PHONY: cover | ||
cover: | ||
go test $(TEST_FLAGS) -coverprofile=cover.out -covermode=atomic -coverpkg=./... ./... | ||
go tool cover -html=cover.out -o cover.html | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -rf _tmp | ||
.PHONY: golangci-lint | ||
golangci-lint: | ||
golangci-lint run | ||
|
||
.PHONY: install | ||
run: install | ||
sally | ||
.PHONY: tidy | ||
tidy: | ||
go mod tidy | ||
|
||
.PHONY: tidy-lint | ||
tidy-lint: | ||
go mod tidy | ||
git diff --exit-code -- go.mod go.sum |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.