From 00ebf584ffca41d5fab4c7b8aaa5b5bfe2fcd0ef Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Tue, 25 Mar 2025 03:34:46 +0100 Subject: [PATCH] chore: update linter --- .github/workflows/go-cross.yml | 2 - .github/workflows/main.yml | 6 +- .golangci.yml | 188 ++++++++++++++++----------------- 3 files changed, 96 insertions(+), 100 deletions(-) diff --git a/.github/workflows/go-cross.yml b/.github/workflows/go-cross.yml index ab88a1b..19d8d49 100644 --- a/.github/workflows/go-cross.yml +++ b/.github/workflows/go-cross.yml @@ -3,11 +3,9 @@ name: Go Matrix on: push: branches: - - master - main pull_request: branches: - - master - main jobs: diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6553e37..45591d0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,11 +3,9 @@ name: Main on: push: branches: - - master - main pull_request: branches: - - master - main jobs: @@ -17,7 +15,7 @@ jobs: runs-on: ubuntu-latest env: GO_VERSION: stable - GOLANGCI_LINT_VERSION: v1.64.6 + GOLANGCI_LINT_VERSION: v2.0.1 CGO_ENABLED: 0 steps: @@ -36,7 +34,7 @@ jobs: # https://golangci-lint.run/usage/install#other-ci - name: Install golangci-lint ${{ env.GOLANGCI_LINT_VERSION }} run: | - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCI_LINT_VERSION} + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCI_LINT_VERSION} golangci-lint --version - name: Make diff --git a/.golangci.yml b/.golangci.yml index c006816..c701858 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,108 +1,108 @@ +version: "2" + +formatters: + enable: + - gci + - gofumpt + settings: + gofumpt: + extra-rules: true + linters: - enable-all: true + default: all disable: - - tenv # deprecated - - sqlclosecheck # not relevant (SQL) - - rowserrcheck # not relevant (SQL) - cyclop # duplicate of gocyclo - - lll - dupl - - prealloc - - wsl - - nlreturn - - mnd - - testpackage - - paralleltest - - tparallel - err113 - - wrapcheck - exhaustive - exhaustruct - - varnamelen + - lll + - mnd - nilnil + - nlreturn + - paralleltest + - prealloc + - rowserrcheck # not relevant (SQL) + - sqlclosecheck # not relevant (SQL) + - testpackage + - tparallel + - varnamelen + - wrapcheck + - wsl + settings: + depguard: + rules: + main: + deny: + - pkg: github.com/instana/testify + desc: not allowed + - pkg: github.com/pkg/errors + desc: Should be replaced by standard lib errors package + forbidigo: + forbid: + - pattern: ^print(ln)?$ + - pattern: ^spew\.Print(f|ln)?$ + - pattern: ^spew\.Dump$ + funlen: + lines: -1 + statements: 40 + goconst: + min-len: 3 + min-occurrences: 3 + gocritic: + disabled-checks: + - sloppyReassign + - rangeValCopy + - octalLiteral + - paramTypeCombine # already handle by gofumpt.extra-rules + enabled-tags: + - diagnostic + - style + - performance + settings: + hugeParam: + sizeThreshold: 100 + gocyclo: + min-complexity: 12 + godox: + keywords: + - FIXME + gomoddirectives: + replace-allow-list: + - github.com/abbot/go-http-auth + - github.com/go-check/check + - github.com/gorilla/mux + - github.com/mailgun/minheap + - github.com/mailgun/multibuf + - github.com/jaguilar/vt100 + gosec: + excludes: + - G204 # Subprocess launched with a potential tainted input or cmd arguments + - G301 # Expect directory permissions to be 0750 or less + - G306 # Expect WriteFile permissions to be 0600 or less + govet: + disable: + - fieldalignment + enable-all: true + misspell: + locale: US -linters-settings: - govet: - enable-all: true - disable: - - fieldalignment - gocyclo: - min-complexity: 12 - goconst: - min-len: 3 - min-occurrences: 3 - misspell: - locale: US - gofumpt: - extra-rules: true - depguard: + exclusions: + presets: + - comments rules: - main: - deny: - - pkg: "github.com/instana/testify" - desc: not allowed - - pkg: "github.com/pkg/errors" - desc: Should be replaced by standard lib errors package - funlen: - lines: -1 - statements: 40 - godox: - keywords: - - FIXME - gocritic: - enabled-tags: - - diagnostic - - style - - performance - disabled-checks: - - sloppyReassign - - rangeValCopy - - octalLiteral - - paramTypeCombine # already handle by gofumpt.extra-rules - settings: - hugeParam: - sizeThreshold: 100 - forbidigo: - forbid: - - '^print(ln)?$' - - '^spew\.Print(f|ln)?$' - - '^spew\.Dump$' - gomoddirectives: - replace-allow-list: - - github.com/abbot/go-http-auth - - github.com/go-check/check - - github.com/gorilla/mux - - github.com/mailgun/minheap - - github.com/mailgun/multibuf - - github.com/jaguilar/vt100 - gosec: - excludes: - - G204 # Subprocess launched with a potential tainted input or cmd arguments - - G301 # Expect directory permissions to be 0750 or less - - G306 # Expect WriteFile permissions to be 0600 or less + - linters: + - gochecknoglobals + - gochecknoinits + path: cmd/ + - linters: + - tagalign + path: internal/traefikv[1-3]/ + - path: (.+)\.go$ + text: 'ST1000: at least one file in a package should have a package comment' + - path: (.+)\.go$ + text: 'package-comments: should have a package comment' issues: - exclude-use-default: false max-issues-per-linter: 0 max-same-issues: 0 - exclude: - - 'ST1000: at least one file in a package should have a package comment' - - 'package-comments: should have a package comment' - exclude-rules: - - path: cmd/ - linters: - - gochecknoglobals - - gochecknoinits - - path: internal/traefikv[1-3]/ - linters: - - tagalign - -output: - show-stats: true - sort-results: true - sort-order: - - linter - - file - -run: - timeout: 5m