diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 4e2549c..923ec82 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -14,8 +14,8 @@ jobs: - name: go mod tidy check uses: katexochen/go-tidy-check@v2 - name: golangci-lint - uses: golangci/golangci-lint-action@v6 + uses: golangci/golangci-lint-action@v7 with: - version: v1.64.5 # LINT_VERSION: update version in other places + version: v2.0.1 # LINT_VERSION: update version in other places - id: govulncheck uses: golang/govulncheck-action@v1 diff --git a/.golangci.yml b/.golangci.yml index c43cf21..18a834b 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,3 +1,4 @@ +version: "2" linters: enable: - asasalint @@ -14,7 +15,6 @@ linters: - dupword - durationcheck - err113 - - errcheck - errchkjson - errname - errorlint @@ -33,21 +33,15 @@ linters: - gocritic - gocyclo - godox - - gofmt - - gofumpt - goheader - - goimports - gomoddirectives - gomodguard - goprintffuncname - gosec - - gosimple - - govet - grouper - iface - importas - inamedparam - - ineffassign - interfacebloat - intrange - lll @@ -79,111 +73,124 @@ linters: - sloglint - sqlclosecheck - staticcheck - - stylecheck - tagalign - tagliatelle - testifylint - testpackage - thelper - tparallel - - typecheck - unconvert - unparam - - unused - usestdlibvars - usetesting - - wastedassign + - wastedassign - whitespace - wrapcheck - wsl - zerologlint - -linters-settings: - errcheck: - check-blank: true - disable-default-exclusions: true - errchkjson: - report-no-exported: true - dupl: - threshold: 120 - tagliatelle: - case: - use-field-name: true - rules: - yaml: kebab - forbidigo: - forbid: - - 'time\.Sleep*(# Do not sleep)?' - - 'panic*(# Do not panic)?' - - 'os\.Exit*(# Do not exit)?' - - p: ^fmt\.Print*$ - msg: Do not commit print statements. - funlen: - ignore-comments: true - gocognit: - min-complexity: 20 - gocyclo: - min-complexity: 20 - goconst: - numbers: true - min-occurrences: 3 - grouper: - import-require-single-import: true - iface: - enable: - - identical - - unused - testifylint: - enable-all: true - unparam: - check-exported: true - nolintlint: - require-explanation: true - maintidx: - under: 40 - misspell: - locale: US - govet: - enable-all: true - disable: - - fieldalignment - lll: - line-length: 100 - tab-width: 1 - nlreturn: - block-size: 5 - goimports: - local-prefixes: github.com/vladopajic/go-test-coverage/v2 - wsl: - force-err-cuddling: true - -issues: - exclude-rules: - - path: _test\.go - linters: - - funlen ## Function length is okay due to many tests cases - - wrapcheck ## No need to check wrapping errors in tests - - maintidx ## Test are okay to be long - - - linters: - - gosec - path: _test\.go - text: "G404" ## allow weak rand in tests - - - path: export_test\.go - linters: - - revive ## Disabling linter because we intentionally want to use unexported types in tests - - gochecknoglobals ## Global values are useful when exporting functions - - - path: _test\.go ## Enable dot-imports in tests - text: "dot-imports" - linters: - - revive - - - text: "require-error" ## Option to disable this error does not work - linters: - - testifylint - - - text: "do not define dynamic errors" ## dynamic errors are okay is this is simple tool - linters: - - err113 \ No newline at end of file + settings: + dupl: + threshold: 120 + errcheck: + disable-default-exclusions: true + check-blank: true + errchkjson: + report-no-exported: true + forbidigo: + forbid: + - pattern: time\.Sleep*(# Do not sleep)? + - pattern: panic*(# Do not panic)? + - pattern: os\.Exit*(# Do not exit)? + - pattern: ^fmt\.Print*$ + msg: Do not commit print statements. + funlen: + ignore-comments: true + gocognit: + min-complexity: 20 + goconst: + min-occurrences: 3 + numbers: true + gocyclo: + min-complexity: 20 + govet: + disable: + - fieldalignment + enable-all: true + grouper: + import-require-single-import: true + iface: + enable: + - identical + - unused + lll: + line-length: 100 + tab-width: 1 + maintidx: + under: 40 + misspell: + locale: US + nlreturn: + block-size: 5 + nolintlint: + require-explanation: true + tagliatelle: + case: + rules: + yaml: kebab + use-field-name: true + testifylint: + enable-all: true + unparam: + check-exported: true + wsl: + force-err-cuddling: true + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + rules: + - linters: + - funlen ## Function length is okay due to many tests cases + - maintidx ## No need to check wrapping errors in tests + - wrapcheck ## Test are okay to be long + path: _test\.go + - linters: + - gosec + path: _test\.go + text: G404 ## allow weak rand in tests + - linters: + - gochecknoglobals ## Global values are useful when exporting functions + - revive ## Disabling linter because we intentionally want to use unexported types in tests + path: export_test\.go + - linters: + - revive + path: _test\.go + text: dot-imports ## Enable dot-imports in tests + - linters: + - testifylint + text: require-error + - linters: + - err113 + text: do not define dynamic errors ## dynamic errors are okay is this is simple tool + paths: + - third_party$ + - builtin$ + - examples$ +formatters: + enable: + - gofmt + - gofumpt + - goimports + settings: + goimports: + local-prefixes: + - github.com/vladopajic/go-test-coverage/v2 + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$ diff --git a/Makefile b/Makefile index b43e426..53ad7f3 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ GO ?= go GOBIN ?= $$($(GO) env GOPATH)/bin GOLANGCI_LINT ?= $(GOBIN)/golangci-lint -GOLANGCI_LINT_VERSION ?= v1.64.5 # LINT_VERSION: update version in other places +GOLANGCI_LINT_VERSION ?= v2.0.1 # LINT_VERSION: update version in other places # Code tidy .PHONY: tidy