From c2aedd5a45df4002219bf1e984ac9caa6c360576 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 25 Mar 2025 07:23:26 +0000 Subject: [PATCH] Bump FollowTheProcess/ci from 1 to 2 (#38) * Bump FollowTheProcess/ci from 1 to 2 Bumps [FollowTheProcess/ci](https://github.com/followtheprocess/ci) from 1 to 2. - [Release notes](https://github.com/followtheprocess/ci/releases) - [Commits](https://github.com/followtheprocess/ci/compare/v1...v2) --- updated-dependencies: - dependency-name: FollowTheProcess/ci dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] * Upgrade to golangci-lint v2 --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Tom Fleet --- .github/workflows/CI.yml | 2 +- .golangci.yml | 251 +++++++++++++++++++++------------------ 2 files changed, 139 insertions(+), 114 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 21a46ca..aa1cda6 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -17,4 +17,4 @@ jobs: name: CI permissions: contents: read - uses: FollowTheProcess/ci/.github/workflows/Go.yml@v1 + uses: FollowTheProcess/ci/.github/workflows/Go.yml@v2 diff --git a/.golangci.yml b/.golangci.yml index 4ede9b0..ce6e02f 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,5 +1,16 @@ +version: "2" + +formatters: + enable: + - gofumpt + - goimports + + settings: + gofumpt: + extra-rules: true + linters: - enable-all: true + default: all disable: - decorder # Don't care about this - dupl # Basically every table driven test ever triggers this @@ -8,9 +19,9 @@ linters: - exhaustruct # No - forbidigo # Nothing to forbid - funlen # Bad metric for complexity - - gci # gofmt/goimports is fine - ginkgolinter # I don't use whatever this is - gochecknoglobals # Globals are fine sometimes, use common sense + - gocognit # Cmplexity with another name, don't need both - gocyclo # cyclop does this instead - godox # "todo" and "fixme" comments are allowed - goheader # No need @@ -22,120 +33,134 @@ linters: - nestif # cyclop does this - nlreturn # Similar to wsl, I think best left to judgement - nonamedreturns # Named returns are often helpful, it's naked returns that are the issue - - paralleltest # No need - - tenv # Replaced by usetesting - - thelper # Lots of false positives due to the way I do table tests in here + - paralleltest # I've never had Go tests take longer than a few seconds, it's fine + - thelper # Lots of false positives in here due to the way I do table tests + - unparam # gopls is better and more subtle - varnamelen # Lots of false positives of things that are fine - wrapcheck # Not every error must be wrapped - wsl # Very aggressive, some of this I like but tend to do anyway -issues: - exclude-rules: - - path: _test\.go - linters: - - prealloc # These kinds of optimisations will make no difference to test code - -linters-settings: - cyclop: - max-complexity: 20 - - depguard: - rules: - main: - deny: - - pkg: io/ioutil - desc: io/ioutil is deprecated, use io instead - - - pkg: "math/rand$" - desc: use math/rand/v2 instead - - errcheck: - check-type-assertions: true - check-blank: true - - exhaustive: - check: - - switch - - map - default-signifies-exhaustive: true - - staticcheck: - checks: - - all - - gosimple: - checks: - - all - - govet: - enable-all: true - - gofumpt: - extra-rules: true - - nakedret: - max-func-lines: 0 # Disallow any naked returns - - nolintlint: - allow-unused: false - require-explanation: true - require-specific: true - - usetesting: - context-background: true - context-todo: true - os-chdir: true - os-mkdir-temp: true - os-setenv: true - os-create-temp: true - os-temp-dir: true - - revive: - max-open-files: 256 - ignore-generated-header: true - enable-all-rules: true + exclusions: + presets: + # See https://golangci-lint.run/usage/false-positives/#exclusion-presets + - comments # Revive in particular has lots of false positives + - std-error-handling + - common-false-positives rules: - - name: add-constant - disabled: true # goconst does this - - - name: argument-limit - arguments: - - 5 - - - name: cognitive-complexity - disabled: true # gocognit does this - - - name: comment-spacings - arguments: - - "nolint:" - - - name: cyclomatic - disabled: true # cyclop does this - - - name: exported - arguments: - - checkPrivateReceivers - - checkPublicInterface - - - name: function-length - disabled: true # Bad proxy for complexity - - - name: function-result-limit - arguments: - - 3 - - - name: import-shadowing - disabled: true # predeclared does this - - - name: line-length-limit - disabled: true # gofmt/golines handles this well enough - - - name: redefines-builtin-id - disabled: true # predeclared does this + - path: _test\.go + linters: + - prealloc # These kinds of optimisations will make no difference to test code + - gosec # Tests don't need security stuff + + settings: + cyclop: + max-complexity: 20 + + depguard: + rules: + main: + deny: + - pkg: io/ioutil + desc: io/ioutil is deprecated, use io instead + + - pkg: "math/rand$" + desc: use math/rand/v2 instead + + errcheck: + check-type-assertions: true + check-blank: true + + exhaustive: + check: + - switch + - map + default-signifies-exhaustive: true + + staticcheck: + checks: + - all + + gosec: + excludes: + - G104 # Errors not checked, handled by errcheck + + govet: + enable-all: true + + nakedret: + max-func-lines: 0 # Disallow any naked returns + + nolintlint: + allow-unused: false + require-explanation: true + require-specific: true + + usetesting: + context-background: true + context-todo: true + os-chdir: true + os-mkdir-temp: true + os-setenv: true + os-create-temp: true + os-temp-dir: true + + revive: + max-open-files: 256 + enable-all-rules: true + rules: + - name: add-constant + disabled: true # goconst does this + + - name: argument-limit + arguments: + - 5 + + - name: cognitive-complexity + disabled: true # gocognit does this + + - name: comment-spacings + arguments: + - "nolint:" + + - name: cyclomatic + disabled: true # cyclop does this + + - name: exported + arguments: + - checkPrivateReceivers + - checkPublicInterface + + - name: function-length + disabled: true # Bad proxy for complexity + + - name: function-result-limit + arguments: + - 3 + + - name: import-shadowing + disabled: true # predeclared does this + + - name: line-length-limit + disabled: true # gofmt/golines handles this well enough + + - name: max-public-structs + disabled: true # This is a dumb rule + + - name: redefines-builtin-id + disabled: true # predeclared does this + + - name: unhandled-error + arguments: + - fmt\.(Fp|P)rint(ln|f)? + - strings.Builder.Write(String|Byte)? + - bytes.Buffer.Write(String|Byte)? + - go/printer.(Fp|P)rint(ln|f)? + + - name: flag-parameter + disabled: true # As far as I can work out this just doesn't like bools + + - name: unused-parameter + disabled: true # The gopls unused analyzer covers this better - - name: unhandled-error - arguments: - - fmt\.(Fp|P)rint(ln|f)? - - strings.Builder.Write(String|Byte)? - - bytes.Buffer.Write(String|Byte)? - - go/printer\.(Fp|P)rint(ln|f)? + - name: unused-receiver + disabled: true # As above -- knotmirror 0.0.1