-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use golangci-lint as linter This is faster than `goimports` and includes more linters. Also removed non user-runnable targets from Makefile. Finally, applied changes to the code to comply with the code.
- Loading branch information
Showing
7 changed files
with
130 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
run: | ||
# timeout for analysis, e.g. 30s, 5m, default is 1m | ||
timeout: 1m | ||
|
||
# include test files or not, default is true | ||
tests: true | ||
|
||
# list of build tags, all linters use it. Default is empty list. | ||
build-tags: [] | ||
|
||
# settings of specific linters | ||
linters-settings: | ||
govet: | ||
check-shadowing: false | ||
golint: | ||
min-confidence: 0 | ||
maligned: | ||
suggest-new: true | ||
dupl: | ||
threshold: 100 | ||
goconst: | ||
min-len: 2 | ||
min-occurrences: 2 | ||
misspell: | ||
locale: US | ||
gocritic: | ||
enabled-tags: | ||
- diagnostic | ||
- experimental | ||
- opinionated | ||
- style | ||
disabled-checks: | ||
- dupImport # https://github.com/go-critic/go-critic/issues/845 | ||
- ifElseChain | ||
- octalLiteral | ||
- wrapperFunc | ||
|
||
linters: | ||
disable-all: true | ||
enable: | ||
- bodyclose | ||
- deadcode | ||
- depguard | ||
- dogsled | ||
- dupl | ||
- errcheck | ||
- goconst | ||
- gocritic | ||
- gofmt | ||
- goimports | ||
- golint | ||
- gosec | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
- interfacer | ||
- misspell | ||
- nakedret | ||
- scopelint | ||
- staticcheck | ||
- structcheck | ||
- stylecheck | ||
- typecheck | ||
- unconvert | ||
- unparam | ||
- unused | ||
- varcheck | ||
- whitespace | ||
|
||
# don't enable: | ||
# - funlen | ||
# - gochecknoglobals | ||
# - gocognit | ||
# - gocyclo | ||
# - godox | ||
# - lll | ||
# - maligned | ||
# - prealloc | ||
# - gochecknoinits | ||
|
||
|
||
issues: | ||
# Excluding configuration per-path, per-linter, per-text and per-source | ||
exclude-rules: | ||
# Exclude some linters from running on tests files. | ||
- path: _test\.go | ||
linters: | ||
- gocyclo | ||
- errcheck | ||
- dupl | ||
- gosec | ||
- scopelint | ||
- goconst | ||
- funlen | ||
- gocritic | ||
|
||
# Maximum issues count per one linter. Set to 0 to disable. Default is 50. | ||
max-issues-per-linter: 0 | ||
|
||
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3. | ||
max-same-issues: 0 | ||
|
||
# Show only new issues: if there are unstaged changes or untracked files, | ||
# only those changes are analyzed, else only changes in HEAD~ are analyzed. | ||
# It's a super-useful option for integration of golangci-lint into existing | ||
# large codebase. It's not practical to fix all existing issues at the moment | ||
# of integration: much better don't allow issues in new code. | ||
# Default is false. | ||
new: 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,18 +1,19 @@ | ||
language: go | ||
|
||
go: | ||
- "1.11.x" | ||
- "1.12.x" | ||
- "1.13.x" | ||
|
||
env: | ||
- GO111MODULE=on | ||
|
||
install: | ||
- make install | ||
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.20.1 | ||
|
||
script: | ||
- make test | ||
- make check-fmt | ||
- make lint | ||
|
||
after_success: | ||
- make report-coveralls | ||
- go get github.com/mattn/goveralls | ||
- goveralls -coverprofile=coverage.out -service=travis-ci |
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,25 +1,16 @@ | ||
.PHONY: test benchmark help fmt install | ||
.PHONY: test help fmt report-coveralls benchmark lint | ||
|
||
help: ## Show the help text | ||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[93m %s\n", $$1, $$2}' | ||
|
||
test: ## Run unit tests | ||
@go test -coverprofile=coverage.out -covermode=atomic -race ./... | ||
|
||
benchmark: ## Run benchmarks | ||
@go test -bench=. ./... | ||
|
||
check-fmt: ## Check file forma | ||
@GOIMP=$$(for f in $$(find . -type f -name "*.go" ! -path "./.cache/*" ! -path "./vendor/*" ! -name "bindata.go") ; do \ | ||
goimports -l $$f ; \ | ||
done) && echo $$GOIMP && test -z "$$GOIMP" | ||
lint: # Run linters using golangci-lint | ||
@golangci-lint run | ||
|
||
fmt: ## Format files | ||
@goimports -w $$(find . -name "*.go" -not -path "./vendor/*") | ||
|
||
install: ## Installs dependencies | ||
GOPATH=$$GOPATH && go get -u -v \ | ||
golang.org/x/tools/cmd/goimports | ||
|
||
report-coveralls: ## Reports generated coverage profile to coveralls.io. Intended to be used only from travis | ||
go get github.com/mattn/goveralls && goveralls -coverprofile=coverage.out -service=travis-ci | ||
benchmark: ## Run benchmarks | ||
@go test -run=NONE -benchmem -benchtime=5s -bench=. ./... |
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
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