Skip to content

Commit ae54675

Browse files
authored
Merge pull request #120 from seatgeek/codell-linter-config
Upgrade golangci-lint to v2.10.0 and configure new linters
2 parents 88cb5ae + b2175fa commit ae54675

File tree

3 files changed

+43
-5
lines changed

3 files changed

+43
-5
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# renovate: datasource=go depName=github.com/golangci/golangci-lint
2-
GOLANGCI_LINT_VERSION=v2.6.2
2+
GOLANGCI_LINT_VERSION=v2.10.0
33
# renovate: datasource=go depName=gotest.tools/gotestsum
44
GOTESTSUM_VERSION=v1.13.0
55
# renovate: datasource=go depName=github.com/boumenot/gocover-cobertura

build/config/.golangci.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ formatters:
2222
## disabled
2323
#- gofmt # checks if the code is formatted according to 'gofmt' command
2424
#- golines # checks if code is formatted, and fixes long lines
25+
#- swaggo # check if swaggo comments are formatted
2526

2627
linters:
2728
default: none
@@ -37,6 +38,7 @@ linters:
3738
- decorder # checks declaration order and count of types, constants, variables and functions
3839
- dogsled # checks assignments with too many blank identifiers (e.g. x, _, _, _, := f())
3940
- durationcheck # checks for two durations multiplied together
41+
- embeddedstructfieldcheck # embedded types should be first in the struct definition
4042
- errcheck # checking for unchecked errors, these unchecked errors can be critical bugs in some cases
4143
- errchkjson # checks types passed to the json encoding functions. Reports unsupported types and optionally reports occasions, where the check for the returned error can be omitted
4244
- errname # checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error
@@ -49,6 +51,7 @@ linters:
4951
- goconst # finds repeated strings that could be replaced by a constant
5052
- gocritic # provides diagnostics that check for bugs, performance and style issues
5153
- gocyclo # computes and checks the cyclomatic complexity of functions
54+
- godoclint # checks Golang's documentation practice (godoc)
5255
- gomoddirectives # manages the use of 'replace', 'retract', and 'excludes' directives in go.mod
5356
- gomodguard # allow and block lists linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations
5457
- goprintffuncname # checks that printf-like functions are named with f at the end
@@ -59,10 +62,12 @@ linters:
5962
- ineffassign # detects when assignments to existing variables are not used
6063
- interfacebloat # checks the number of methods inside an interface
6164
- intrange # check for loops that could use int ranges instead (Go 1.22+)
65+
- iotamixing # checks for mixing of iota and non-iota constants in the same block
6266
- loggercheck # checks key value pairs for common logger libraries (kitlog,klog,logr,zap)
6367
- makezero # finds slice declarations with non-zero initial length
6468
- mirror # suggests alternative functions to avoid unnecessary []byte/string conversions
6569
- misspell # finds commonly misspelled English words in comments
70+
- modernize # suggests simplifications to Go code, using modern language and library features
6671
- musttag # checks that struct tags are present
6772
- nakedret # finds naked returns in functions greater than a specified function length
6873
- nestif # reports deeply nested if statements
@@ -95,13 +100,15 @@ linters:
95100
- whitespace # detects leading and trailing whitespace
96101

97102
## disabled
103+
#- arangolint # opinionated best practices for arangodb client
98104
#- cyclop # checks function and package cyclomatic complexity
99105
#- depguard # [replaced by gomodguard] checks if package imports are in a list of acceptable packages
100106
#- dupl # finds duplicated code
101107
#- dupword # [useless without config] checks for duplicate words in the source code
102108
#- err113 # [too strict] checks the errors handling expression
103109
#- exhaustruct # [highly recommend to enable] checks if all structure fields are initialized
104110
#- forcetypeassert # [replaced by errcheck] finds forced type assertions
111+
#- funcorder # checks the order of functions, methods, and constructors
105112
#- funlen # tool for detection of long functions
106113
#- ginkgolinter # [if you use ginkgo/gomega] enforces standards of using ginkgo and gomega
107114
#- gochecknoglobals # checks that no global variables exist
@@ -121,20 +128,26 @@ linters:
121128
#- maintidx # measures the maintainability index of each function
122129
#- mnd # detects magic numbers
123130
#- nilnil # checks that there is no simultaneous return of nil error and an invalid value
131+
#- noinlineerr # disallows inline error handling
124132
#- nonamedreturns # reports all named returns
125133
#- nlreturn # [too strict and mostly code is not more readable] checks for a new line before return and branch statements to increase code clarity
126134
#- promlinter # checks Prometheus metrics naming via promlint
127135
#- stylecheck # is a replacement for golint
128136
#- tagliatelle # checks the struct tags
129137
#- testpackage # makes you use a separate _test package
130138
#- unparam # reports unused function parameters
139+
#- unqueryvet # checks for SQL issues
131140
#- usestdlibvars # detects the possibility to use variables/constants from the Go standard library
132141
#- varnamelen # [great idea, but too many false positives] checks that the length of a variable's name matches its scope
133142
#- wrapcheck # checks that errors returned from external packages are wrapped
134143
#- wsl # [too strict and mostly code is not more readable] whitespace linter forces you to use empty lines
135144
#- zerologlint # [if you use zerolog] detects the wrong usage of zerolog that a user forgets to dispatch with Send or Msg
136145

137146
settings:
147+
embeddedstructfieldcheck:
148+
empty-line: false
149+
forbid-mutex: true
150+
138151
errcheck:
139152
check-type-assertions: true
140153
exclude-functions:
@@ -146,6 +159,13 @@ linters:
146159
goconst:
147160
min-occurrences: 3
148161

162+
godoclint:
163+
default: none
164+
enable:
165+
- deprecated
166+
- require-stdlib-doclink
167+
- single-pkg-doc
168+
149169
gomodguard:
150170
blocked:
151171
modules:
@@ -203,17 +223,25 @@ linters:
203223
- name: early-return
204224
disabled: false
205225
arguments: [preserveScope]
226+
- name: epoch-naming
227+
disabled: false
206228
- name: error-naming
207229
disabled: false
208230
- name: error-return
209231
disabled: false
232+
- name: forbidden-call-in-wg-go
233+
disabled: false
210234
- name: if-return
211235
disabled: false
236+
- name: inefficient-map-lookup
237+
disabled: false
212238
- name: max-control-nesting
213239
disabled: false
214240
arguments: [3]
215241
- name: optimize-operands-order
216242
disabled: false
243+
- name: package-directory-mismatch
244+
disabled: false
217245
- name: range
218246
disabled: false
219247
- name: receiver-naming
@@ -237,14 +265,24 @@ linters:
237265
disabled: false
238266
- name: unexported-naming
239267
disabled: false
268+
- name: unnecessary-format
269+
disabled: false
270+
- name: unnecessary-if
271+
disabled: false
240272
- name: unnecessary-stmt
241273
disabled: false
242274
- name: unreachable-code
243275
disabled: false
244276
- name: use-any
245277
disabled: false
278+
- name: use-fmt-print
279+
disabled: false
280+
- name: use-slices-sort
281+
disabled: false
246282
- name: useless-break
247283
disabled: false
284+
- name: useless-fallthrough
285+
disabled: false
248286
- name: var-declaration
249287
disabled: false
250288
- name: waitgroup-by-value

pkg/notifier/slack/slack_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ func TestNewTransport(t *testing.T) {
2626
token string
2727
opts []slackgo.Option
2828
}{
29-
{
29+
{ //nolint:gosec // fake test token
3030
name: "creates transport with key and token",
3131
key: "slack",
3232
token: "xoxb-test-token",
3333
opts: nil,
3434
},
35-
{
35+
{ //nolint:gosec // fake test token
3636
name: "creates transport with options",
3737
key: "custom-slack",
3838
token: "xoxb-another-token",
@@ -296,10 +296,10 @@ func TestTransport_Validate(t *testing.T) {
296296
token string
297297
wantErr bool
298298
}{
299-
{
299+
{ //nolint:gosec // fake test token
300300
name: "validation with fake token returns error",
301301
token: "xoxb-fake-token",
302-
wantErr: true, // Expect error with fake token
302+
wantErr: true,
303303
},
304304
{
305305
name: "validation with empty token returns error",

0 commit comments

Comments
 (0)