Skip to content

Commit

Permalink
Refactor/enforce stricter go linters (#93)
Browse files Browse the repository at this point in the history
* Merge branch 'perf/make-slices-more-efficient'

* refactor: everything to stop new linters from crying

* Squashed commit of the following:

commit ae78197
Author: Jonathan Mayer <[email protected]>
Date:   Mon Jan 13 09:35:27 2025 +0100

    perf: reduce memory allocations (#81)

    * perf: reduce memory allocations

    * perf: avoid preallocating the slice with zero values

    * perf: avoid temporary copies in get resource functions

commit ad608b6
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Mon Jan 13 08:21:37 2025 +0100

    chore(deps): bump github.com/zalando-incubator/stackset-controller from 1.4.84 to 1.4.92 (#94)

    * chore(deps): bump github.com/zalando-incubator/stackset-controller

    Bumps [github.com/zalando-incubator/stackset-controller](https://github.com/zalando-incubator/stackset-controller) from 1.4.84 to 1.4.92.
    - [Release notes](https://github.com/zalando-incubator/stackset-controller/releases)
    - [Commits](zalando-incubator/stackset-controller@v1.4.84...v1.4.92)

    ---
    updated-dependencies:
    - dependency-name: github.com/zalando-incubator/stackset-controller
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...

    Signed-off-by: dependabot[bot] <[email protected]>

    * chore: bump deps dependabot didnt

    ---------

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: jonathan-mayer <[email protected]>

commit 48d222f
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Fri Jan 10 07:47:01 2025 +0100

    chore(deps): bump github.com/prometheus-operator/prometheus-operator/pkg/client (#87)

    Bumps [github.com/prometheus-operator/prometheus-operator/pkg/client](https://github.com/prometheus-operator/prometheus-operator) from 0.76.2 to 0.79.2.
    - [Release notes](https://github.com/prometheus-operator/prometheus-operator/releases)
    - [Changelog](https://github.com/prometheus-operator/prometheus-operator/blob/main/CHANGELOG.md)
    - [Commits](prometheus-operator/prometheus-operator@v0.76.2...v0.79.2)

    ---
    updated-dependencies:
    - dependency-name: github.com/prometheus-operator/prometheus-operator/pkg/client
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit e856e24
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Fri Jan 10 07:38:58 2025 +0100

    chore(deps): bump github.com/kedacore/keda/v2 from 2.15.1 to 2.16.1 (#90)

    * chore(deps): bump github.com/kedacore/keda/v2 from 2.15.1 to 2.16.1

    Bumps [github.com/kedacore/keda/v2](https://github.com/kedacore/keda) from 2.15.1 to 2.16.1.
    - [Release notes](https://github.com/kedacore/keda/releases)
    - [Changelog](https://github.com/kedacore/keda/blob/main/CHANGELOG.md)
    - [Commits](kedacore/keda@v2.15.1...v2.16.1)

    ---
    updated-dependencies:
    - dependency-name: github.com/kedacore/keda/v2
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...

    Signed-off-by: dependabot[bot] <[email protected]>

    * chore: automatically push pre-commit changes

    * Merge remote-tracking branch 'origin/main'

    * Squashed commit of the following:

    commit 5cf9b47
    Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Date:   Fri Jan 10 07:19:20 2025 +0100

        chore(deps): bump k8s.io/api from 0.31.0 to 0.32.0 (#89)

        * chore(deps): bump k8s.io/api from 0.31.0 to 0.32.0

        Bumps [k8s.io/api](https://github.com/kubernetes/api) from 0.31.0 to 0.32.0.
        - [Commits](kubernetes/api@v0.31.0...v0.32.0)

        ---
        updated-dependencies:
        - dependency-name: k8s.io/api
          dependency-type: direct:production
          update-type: version-update:semver-minor
        ...

        Signed-off-by: dependabot[bot] <[email protected]>

        * fix: bump client-go to match with other dependencies

        ---------

        Signed-off-by: dependabot[bot] <[email protected]>
        Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
        Co-authored-by: jonathan-mayer <[email protected]>

    commit 7c5dc08
    Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Date:   Fri Jan 10 07:03:48 2025 +0100

        chore(deps): bump golang from 1.23.1 to 1.23.4 (#91)

        * chore(deps): bump golang from 1.23.1 to 1.23.4

        Bumps golang from 1.23.1 to 1.23.4.

        ---
        updated-dependencies:
        - dependency-name: golang
          dependency-type: direct:production
          update-type: version-update:semver-patch
        ...

        Signed-off-by: dependabot[bot] <[email protected]>

        * chore: bump golang from 1.23.1 to 1.23.4

        ---------

        Signed-off-by: dependabot[bot] <[email protected]>
        Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
        Co-authored-by: jonathan-mayer <[email protected]>

    commit efe5db1
    Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Date:   Fri Jan 10 06:51:57 2025 +0100

        chore(deps): bump actions/setup-go from 5.0.2 to 5.2.0 (#85)

        Bumps [actions/setup-go](https://github.com/actions/setup-go) from 5.0.2 to 5.2.0.
        - [Release notes](https://github.com/actions/setup-go/releases)
        - [Commits](actions/setup-go@v5.0.2...v5.2.0)

        ---
        updated-dependencies:
        - dependency-name: actions/setup-go
          dependency-type: direct:production
          update-type: version-update:semver-minor
        ...

        Signed-off-by: dependabot[bot] <[email protected]>
        Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

    commit 952f8b2
    Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Date:   Fri Jan 10 06:51:28 2025 +0100

        chore(deps): bump docker/build-push-action from 5 to 6 (#84)

        Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 5 to 6.
        - [Release notes](https://github.com/docker/build-push-action/releases)
        - [Commits](docker/build-push-action@v5...v6)

        ---
        updated-dependencies:
        - dependency-name: docker/build-push-action
          dependency-type: direct:production
          update-type: version-update:semver-major
        ...

        Signed-off-by: dependabot[bot] <[email protected]>
        Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

    * Squashed commit of the following:

    commit 5cf9b47
    Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Date:   Fri Jan 10 07:19:20 2025 +0100

        chore(deps): bump k8s.io/api from 0.31.0 to 0.32.0 (#89)

        * chore(deps): bump k8s.io/api from 0.31.0 to 0.32.0

        Bumps [k8s.io/api](https://github.com/kubernetes/api) from 0.31.0 to 0.32.0.
        - [Commits](kubernetes/api@v0.31.0...v0.32.0)

        ---
        updated-dependencies:
        - dependency-name: k8s.io/api
          dependency-type: direct:production
          update-type: version-update:semver-minor
        ...

        Signed-off-by: dependabot[bot] <[email protected]>

        * fix: bump client-go to match with other dependencies

        ---------

        Signed-off-by: dependabot[bot] <[email protected]>
        Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
        Co-authored-by: jonathan-mayer <[email protected]>

    commit 7c5dc08
    Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Date:   Fri Jan 10 07:03:48 2025 +0100

        chore(deps): bump golang from 1.23.1 to 1.23.4 (#91)

        * chore(deps): bump golang from 1.23.1 to 1.23.4

        Bumps golang from 1.23.1 to 1.23.4.

        ---
        updated-dependencies:
        - dependency-name: golang
          dependency-type: direct:production
          update-type: version-update:semver-patch
        ...

        Signed-off-by: dependabot[bot] <[email protected]>

        * chore: bump golang from 1.23.1 to 1.23.4

        ---------

        Signed-off-by: dependabot[bot] <[email protected]>
        Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
        Co-authored-by: jonathan-mayer <[email protected]>

    commit efe5db1
    Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Date:   Fri Jan 10 06:51:57 2025 +0100

        chore(deps): bump actions/setup-go from 5.0.2 to 5.2.0 (#85)

        Bumps [actions/setup-go](https://github.com/actions/setup-go) from 5.0.2 to 5.2.0.
        - [Release notes](https://github.com/actions/setup-go/releases)
        - [Commits](actions/setup-go@v5.0.2...v5.2.0)

        ---
        updated-dependencies:
        - dependency-name: actions/setup-go
          dependency-type: direct:production
          update-type: version-update:semver-minor
        ...

        Signed-off-by: dependabot[bot] <[email protected]>
        Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

    commit 952f8b2
    Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Date:   Fri Jan 10 06:51:28 2025 +0100

        chore(deps): bump docker/build-push-action from 5 to 6 (#84)

        Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 5 to 6.
        - [Release notes](https://github.com/docker/build-push-action/releases)
        - [Commits](docker/build-push-action@v5...v6)

        ---
        updated-dependencies:
        - dependency-name: docker/build-push-action
          dependency-type: direct:production
          update-type: version-update:semver-major
        ...

        Signed-off-by: dependabot[bot] <[email protected]>
        Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

    ---------

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
    Co-authored-by: jonathan-mayer <[email protected]>

commit 5cf9b47
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Fri Jan 10 07:19:20 2025 +0100

    chore(deps): bump k8s.io/api from 0.31.0 to 0.32.0 (#89)

    * chore(deps): bump k8s.io/api from 0.31.0 to 0.32.0

    Bumps [k8s.io/api](https://github.com/kubernetes/api) from 0.31.0 to 0.32.0.
    - [Commits](kubernetes/api@v0.31.0...v0.32.0)

    ---
    updated-dependencies:
    - dependency-name: k8s.io/api
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...

    Signed-off-by: dependabot[bot] <[email protected]>

    * fix: bump client-go to match with other dependencies

    ---------

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: jonathan-mayer <[email protected]>

commit 7c5dc08
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Fri Jan 10 07:03:48 2025 +0100

    chore(deps): bump golang from 1.23.1 to 1.23.4 (#91)

    * chore(deps): bump golang from 1.23.1 to 1.23.4

    Bumps golang from 1.23.1 to 1.23.4.

    ---
    updated-dependencies:
    - dependency-name: golang
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...

    Signed-off-by: dependabot[bot] <[email protected]>

    * chore: bump golang from 1.23.1 to 1.23.4

    ---------

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: jonathan-mayer <[email protected]>

commit efe5db1
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Fri Jan 10 06:51:57 2025 +0100

    chore(deps): bump actions/setup-go from 5.0.2 to 5.2.0 (#85)

    Bumps [actions/setup-go](https://github.com/actions/setup-go) from 5.0.2 to 5.2.0.
    - [Release notes](https://github.com/actions/setup-go/releases)
    - [Commits](actions/setup-go@v5.0.2...v5.2.0)

    ---
    updated-dependencies:
    - dependency-name: actions/setup-go
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit 952f8b2
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Fri Jan 10 06:51:28 2025 +0100

    chore(deps): bump docker/build-push-action from 5 to 6 (#84)

    Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 5 to 6.
    - [Release notes](https://github.com/docker/build-push-action/releases)
    - [Commits](docker/build-push-action@v5...v6)

    ---
    updated-dependencies:
    - dependency-name: docker/build-push-action
      dependency-type: direct:production
      update-type: version-update:semver-major
    ...

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit 0f9015c
Author: Jonathan Mayer <[email protected]>
Date:   Thu Jan 9 14:39:09 2025 +0100

    chore: add dependabot config (#83)

commit f0b9f9e
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Thu Jan 9 14:33:04 2025 +0100

    chore(deps): bump golang.org/x/net from 0.28.0 to 0.33.0 (#82)

    Bumps [golang.org/x/net](https://github.com/golang/net) from 0.28.0 to 0.33.0.
    - [Commits](golang/net@v0.28.0...v0.33.0)

    ---
    updated-dependencies:
    - dependency-name: golang.org/x/net
      dependency-type: indirect
    ...

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: resolve pr threads
  • Loading branch information
jonathan-mayer authored Jan 21, 2025
1 parent 4fcf2d2 commit 3e40c69
Show file tree
Hide file tree
Showing 41 changed files with 1,302 additions and 516 deletions.
211 changes: 203 additions & 8 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,212 @@
issues:
exclude-files:
- ".*_test.go"
linters-settings:
wsl:
allow-cuddle-declarations: true
depguard:
rules:
logger:
deny:
- pkg: "github.com/sirupsen/logrus"
desc: use the standard library's slog.Logger instead
- pkg: "github.com/ueber-go/zap"
desc: use the standard library's slog.Logger instead
dupl:
threshold: 100
funlen:
lines: -1 # the number of lines (code + empty lines) is not a right metric and leads to code without empty line or one-liner.
statements: 50
goconst:
min-len: 2
min-occurrences: 3
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
disabled-checks:
- dupImport # https://github.com/go-critic/go-critic/issues/845
- ifElseChain
- octalLiteral
- whyNoLint
gocyclo:
min-complexity: 15
gofmt:
rewrite-rules:
- pattern: "interface{}"
replacement: "any"
goimports:
local-prefixes: github.com/golangci/golangci-lint
mnd:
# don't include the "operation" and "assign"
checks:
- argument
- case
- condition
- return
ignored-numbers:
- "0"
- "1"
- "2"
- "3"
ignored-functions:
- strings.SplitN

govet:
enable-all: true
disable:
- fieldalignment # disabled because it's too strict, it checks if struct fields are sorted by size
settings:
printf:
funcs:
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
lll:
line-length: 140
misspell:
locale: US
nolintlint:
allow-unused: false # report any unused nolint directives
require-explanation: true # require an explanation for nolint directives
require-specific: true # require nolint directives to be specific about which linter is being skipped
revive:
rules:
- name: unexported-return
disabled: true
- name: unused-parameter

linters:
disable-all: true
enable:
- staticcheck
- asasalint
- asciicheck
- bidichk
- bodyclose
- canonicalheader
- containedctx
- contextcheck
- copyloopvar
- cyclop
- decorder
- depguard
- dogsled
- dupl
- dupword
- durationcheck
- err113
- errcheck
- govet
- ineffassign
- typecheck
- unused
- errchkjson
- errname
- errorlint
- exhaustive
#- exhaustruct # structs, esp. option structs are not always supposed to be exhausted on initialization
- fatcontext
- forbidigo
- forcetypeassert
- funlen
- gci
- ginkgolinter
- gocheckcompilerdirectives
- gochecknoglobals
- gochecknoinits
- gochecksumtype
- gocognit
- goconst
- gocritic
- gocyclo
- godot
- godox
- gofmt
- gofumpt
- goheader
- goimports
- gomoddirectives
- gomodguard
- goprintffuncname
- gosec
- gosimple
- gosmopolitan
- govet
- grouper
- importas
- inamedparam
- ineffassign
- interfacebloat
- intrange
- ireturn
- lll
- loggercheck
- maintidx
- makezero
- mirror
- misspell
- mnd
- musttag
- nakedret
- nestif
- nilerr
- nilnil
#- nlreturn # wsl has a better implementation of the same principle, where you only have to put whitespaces if the block is longer
- noctx
- nolintlint
- nonamedreturns
- nosprintfhostport
- paralleltest
- perfsprint
- prealloc
- predeclared
- promlinter
- protogetter
- reassign
- revive
- rowserrcheck
- sloglint
- spancheck
- sqlclosecheck
- staticcheck
- stylecheck
- tagalign
- tagliatelle
- tenv
- testableexamples
- testifylint
#- testpackage # we might also want to test unexported functions
- thelper
- tparallel
- unconvert
- unparam
- unused
- usestdlibvars
- varnamelen
- wastedassign
- whitespace
- wrapcheck
- wsl
- zerologlint

output:
print-linter-name: true

issues:
max-same-issues: 50
exclude-dirs:
- test/data # test files
- test/testdata # test files
- pb # protobuf files
exclude-rules:
- path: _test\.go
linters:
- mnd # test files can have magic numbers
- revive # test files can have unused parameters
- forcetypeassert # test files can have unchecked type assertion
- wrapcheck # test files can have unwrapped errors
- govet # test files can have global variables
- gochecknoglobals # test files can have global variables
- source: "//nolint: "
linters: [lll] # disable long line linter on lines with '//nolint:' directive
fix: true

run:
timeout: 5m
Loading

0 comments on commit 3e40c69

Please sign in to comment.