Skip to content

Commit

Permalink
.golangci.yml: invert linter selection (enable-all: true + disable)
Browse files Browse the repository at this point in the history
See
#29 (comment)

The idea is that this approach should be easier to maintain in the long
run. CI will still be reproducible because we declare a specific
`golangci-lint` version in `.github/workflows/go.yml` (`version: v1.58`
at the moment), so we'll get a constant set of linters as long as the
`golangci-lint` version stays the same. But at the same time, when we
bump this `golangci-lint` version, we'll get all the new linters by
default without having to change the `.golangci.yml` configuration.

In contrast, with the existing `disable-all: true` + `enable` approach,
we're not using any of the new linters until we manually review the
latest list of linters that `golangci-lint` supports and update
`.golangci.yml` accordingly (which is tedious). Until that is done,
we're probably missing out on some useful linters that could find other
issues in our code.

Of course, it's possible that we won't find all new linters useful, but
we can simply check the `golangci-lint` output after bumping its
version, see which linters we don't care about and then update the
`disable` list accordingly.
  • Loading branch information
generalmimon committed May 4, 2024
1 parent 51c84de commit f26263d
Showing 1 changed file with 38 additions and 81 deletions.
119 changes: 38 additions & 81 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,85 +1,42 @@
# https://github.com/golangci/golangci-lint/blob/v1.44.0/.golangci.example.yml#L1540-L1628
# https://github.com/golangci/golangci-lint/blob/4bf574a12bb61234e28e3d6172be6ed95b0e8baf/.golangci.reference.yml#L2610
linters:
# Disable all linters.
disable-all: true
# Enable specific linter
# https://golangci-lint.run/usage/linters/#enabled-by-default-linters
enable:
- asciicheck
- bidichk
- bodyclose
- contextcheck
- cyclop
# - depguard
- dogsled
- dupl
- durationcheck
- errcheck
- errname
- errorlint
- exhaustive
# - exhaustivestruct
- exportloopref
- forbidigo
- forcetypeassert
- funlen
- gci
- gochecknoglobals
- gochecknoinits
# - gocognit
- goconst
- gocritic
# - gocyclo
# - godot
# - godox
- goerr113
- gofmt
# - gofumpt
# - goheader
# - goimports
# - gomnd
- gomoddirectives
# - gomodguard
# - goprintffuncname
- gosec
- gosimple
- govet
- importas
- ineffassign
- ireturn
- lll
- makezero
- misspell
- nakedret
# - nestif
- nilerr
- nilnil
# - nlreturn
- noctx
- nolintlint
# - paralleltest
- prealloc
- predeclared
- promlinter
- revive
- rowserrcheck
- sqlclosecheck
- staticcheck
- stylecheck
- tagliatelle
- tenv
# - testpackage
- thelper
- tparallel
- typecheck
- unconvert
- unparam
- unused
# - varnamelen
- wastedassign
- whitespace
- wrapcheck
# - wsl
# Enable all available linters.
enable-all: true
# Disable specific linter
# https://golangci-lint.run/usage/linters/#disabled-by-default-linters--e--enable
disable:
- depguard
- exhaustruct
- gocognit
- gocyclo
- godot
- godox
- gofumpt
- goheader
- goimports
- gomodguard
- goprintffuncname
- mnd
- nestif
- nlreturn
- paralleltest
- testpackage
- varnamelen
- wsl

# https://github.com/golangci/golangci-lint/blob/4bf574a12bb61234e28e3d6172be6ed95b0e8baf/.golangci.reference.yml#L2724-L2734
- deadcode # Deprecated
- execinquery # Deprecated
- exhaustivestruct # Deprecated
- golint # Deprecated
- ifshort # Deprecated
- interfacer # Deprecated
- maligned # Deprecated
- gomnd # Deprecated
- nosnakecase # Deprecated
- scopelint # Deprecated
- structcheck # Deprecated
- varcheck # Deprecated
issues:
# List of regexps of issue texts to exclude, empty list by default.
# But independently from this option we use default exclude patterns,
Expand Down

0 comments on commit f26263d

Please sign in to comment.