diff --git a/.golangci.yml b/.golangci.yml index 6365f55..6a7f39d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -23,31 +23,104 @@ linters: - nilerr - nilnil - nolintlint + - nakedret - predeclared - reassign - revive - staticcheck - tagliatelle - tenv + - testpackage - unconvert - unparam - unused - whitespace linters-settings: + errcheck: + check-type-assertions: true + check-blank: true + + exhaustive: + check: + - switch + - map + default-signifies-exhaustive: true + gocyclo: min-complexity: 20 staticcheck: - go: "1.20" checks: ["all"] - errcheck: - check-type-assertions: true - check-blank: true - gosimple: checks: ["all"] govet: enable-all: true + + revive: + max-open-files: 256 + ignore-generated-header: true + rules: + - name: argument-limit + disabled: false + arguments: [5] + + - name: atomic + disabled: false + + - name: blank-imports + disabled: false + + - name: call-to-gc + disabled: false + + - name: constant-logical-expr + disabled: false + + - name: context-as-argument + disabled: false + + - name: datarace + disabled: false + + - name: deep-exit + disabled: false + + - name: defer + disabled: false + + - name: dot-imports + disabled: false + + - name: early-return + disabled: false + + - name: exported + arguments: + - checkPrivateReceivers + + - name: modifies-value-receiver + disabled: false + + - name: package-comments + disabled: false + + - name: range + disabled: false + + - name: range-val-in-closure + disabled: false + + - name: range-val-address + disabled: false + + - name: time-equal + disabled: false + + - name: use-any + disabled: false + + - name: waitgroup-by-value + disabled: false diff --git a/Makefile b/Makefile deleted file mode 100644 index d2efab4..0000000 --- a/Makefile +++ /dev/null @@ -1,38 +0,0 @@ -.PHONY: help tidy fmt test lint doc cover clean check sloc -.DEFAULT_GOAL := help - -COVERAGE_DATA := coverage.out -COVERAGE_HTML := coverage.html - -help: ## Show the list of available tasks - @echo "Available Tasks:\n" - @grep -E '^[a-zA-Z_0-9%-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "%-10s %s\n", $$1, $$2}' - -tidy: ## Tidy dependencies in go.mod - go mod tidy - -fmt: ## Run go fmt on all source files - go fmt ./... - -test: ## Run the test suite - go test -race ./... - -lint: ## Run the linters and auto-fix if possible - golangci-lint run --fix - -doc: ## Render the docs locally - pkgsite -open - -cover: ## Calculate test coverage and render the html - go test -race -cover -covermode atomic -coverprofile $(COVERAGE_DATA) ./... - go tool cover -html $(COVERAGE_DATA) -o $(COVERAGE_HTML) - open $(COVERAGE_HTML) - -clean: ## Remove build artifacts and other clutter - go clean ./... - rm -rf $(COVERAGE_DATA) $(COVERAGE_HTML) - -check: test lint ## Run tests and linting in one go - -sloc: ## Print lines of code (for fun) - find . -name "*.go" | xargs wc -l | sort -nr diff --git a/Taskfile.yml b/Taskfile.yml new file mode 100644 index 0000000..e6f0fce --- /dev/null +++ b/Taskfile.yml @@ -0,0 +1,66 @@ +# https://taskfile.dev + +version: "3" + +vars: + COV_DATA: coverage.out + +tasks: + default: + desc: List all available tasks + silent: true + cmd: task --list + + tidy: + desc: Tidy dependencies in go.mod and go.sum + cmd: go mod tidy + + fmt: + desc: Run go fmt on all source files + cmd: go fmt ./... + + test: + desc: Run the test suite + cmd: go test -race ./... {{ .CLI_ARGS }} + + bench: + desc: Run all project benchmarks + cmd: go test ./... -run None -benchmem -bench . {{ .CLI_ARGS }} + + lint: + desc: Run the linters and auto-fix if possible + cmd: golangci-lint run --fix + preconditions: + - sh: command -v golangci-lint + msg: golangci-lint not installed, see https://golangci-lint.run/usage/install/#local-installation + + doc: + desc: Render the pkg docs locally + cmd: pkgsite -open + preconditions: + - sh: command -v pkgsite + msg: pkgsite not installed, run go install golang.org/x/pkgsite/cmd/pkgsite@latest + + cov: + desc: Calculate test coverage and render the html + generates: + - "{{ .COV_DATA }}" + cmds: + - go test -race -cover -covermode atomic -coverprofile {{ .COV_DATA }} ./... + - go tool cover -html {{ .COV_DATA }} + + check: + desc: Run tests and linting in one + cmds: + - task: test + - task: lint + + sloc: + desc: Print lines of code + cmd: fd . -e go | xargs wc -l | sort -nr | head + + clean: + desc: Remove build artifacts and other clutter + cmds: + - go clean ./... + - rm -rf {{ .COV_DATA }}