-
Notifications
You must be signed in to change notification settings - Fork 775
Expand file tree
/
Copy path.golangci.yaml
More file actions
230 lines (230 loc) · 6.67 KB
/
Copy path.golangci.yaml
File metadata and controls
230 lines (230 loc) · 6.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
version: "2"
run:
concurrency: 4
tests: true
output:
formats:
text:
path: stdout
print-linter-name: true
print-issued-lines: true
linters:
default: none
enable:
- bodyclose
- copyloopvar
- forbidigo
- ginkgolinter
- gomodguard
- gosec
- importas
- ineffassign
- krtequals
- kubeapilinter
- misspell
- modernize
- nakedret
- nestif
- predeclared
- promlinter
- sloglint
- spancheck
- staticcheck
- testifylint
- unparam
- unused
- usestdlibvars
- whitespace
settings:
custom:
krtequals:
type: "module"
description: Checks Equals() implementations for KRT-style semantic equality issues
settings:
deepEqual: false
checkUnexported: true
kubeapilinter:
type: module
description: Kube API Linter lints Kube like APIs based on API conventions and best practices
settings:
linters:
enable:
- "*"
disable:
- commentstart
- integers
- maxlength
- nobools
- nomaps
- optionalfields
- ssatags
lintersConfig:
conditions:
isFirstField: Ignore
useProtobuf: Forbid
usePatchStrategy: Ignore
forbidigo:
forbid:
- pattern: anypb.New
msg: use utils.MessageToAny instead
- pattern: kclient.New$
msg: use kclient.NewFilteredDelayed for CRDs and kclient.NewFiltered for core types, with discovery namespace ObjectFilter instead
- pattern: ^client.Client$
msg: use apiclient.Client instead of controller-runtime's client.Client
- pattern: (\bt|\bT\(\))\.Cleanup
msg: require testutils.Cleanup in e2e tests (test/e2e/)
gomodguard:
blocked:
modules:
- github.com/rotisserie/eris:
recommendations:
- errors.Join
reason: Use the std-lib errors package with \\%w instead.
- github.com/hashicorp/go-multierror:
recommendations:
- errors.Join
reason: Use errors.Join (Go 1.20+) instead.
- github.com/pkg/errors:
recommendations:
- fmt.Errorf
- errors.New
- errors.Join
reason: Use the std-lib errors package and fmt.Errorf with \\%w instead.
importas:
alias:
- pkg: k8s.io/api/apps/v1
alias: appsv1
- pkg: k8s.io/api/core/v1
alias: corev1
- pkg: k8s.io/apimachinery/pkg/apis/meta/v1
alias: metav1
- pkg: k8s.io/api/batch/v1
alias: batchv1
- pkg: sigs.k8s.io/gateway-api/apis/v1
alias: gwv1
- pkg: sigs.k8s.io/gateway-api/apis/v1alpha2
alias: gwv1a2
- pkg: sigs.k8s.io/gateway-api/apis/v1beta1
alias: gwv1b1
- pkg: github.com/envoyproxy/go-control-plane/envoy/config/(\w+)/(v[\w\d]+)
alias: envoy$1$2
- pkg: github.com/envoyproxy/go-control-plane/envoy/extensions/transport_sockets/tls/v3
alias: envoytlsv3
- pkg: github.com/kgateway-dev/kgateway/v2/api/annotations
alias: apiannotations
- pkg: github.com/kgateway-dev/kgateway/v2/api/settings
alias: apisettings
misspell:
ignore-rules:
- kgateway
modernize:
disable:
# disabled because modernize gets confused with conflicting edits. we can probably rely on the kube api linter instead for this one.
- omitzero
nakedret:
# The team consensus is that naked returns hinder the readability of the code.
# However, named return values can still be useful as documentation for certain scenarios.
# By setting this to 0 in lieu of the default 30, we will effectively allow named return
# values as long as they are included in the return statement(s) e.g.
# func foo() (a, b int) {
# a = 1
# b = 2
# c := 3
# d := 4
# // These are allowed
# return a, b
# return c, d
# return d, c
# // This is NOT allowed
# return
# // This is allowed but really, really bad. DO NOT do this.
# return b, a
max-func-lines: 0
nestif:
# This catches only the worst offenders (complexity >= 20)
min-complexity: 20
staticcheck:
checks:
- SA1019 # deprecated usage
- SA2002 # testing.T FailNow/SkipNow called from goroutine
- ST1019 # duplicate imports
testifylint:
disable-all: true
enable:
- go-require # require/assert.FailNow in non-test goroutines
- suite-subtest-run # use s.Run instead of s.T().Run in testify suites
go-require:
ignore-http-handlers: true
sloglint:
static-msg: true
msg-style: lowercased
key-naming-case: snake
# ignore built-in keys
forbidden-keys:
- time
- level
- msg
- source
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
paths:
- test/rules
- gomock_reflect_\d*
- third_party$
- builtin$
- examples$
- hack/dummy-idp
rules:
# Forbid t.Cleanup only in e2e tests (exclude the rule from non-e2e paths)
- path-except: test/e2e/
linters:
- forbidigo
text: 'require testutils.Cleanup'
# unparam is often noisy in tests where helper signatures intentionally stay uniform.
- path: _test\.go$
linters:
- unparam
# Skip client.Client forbidgo rule for e2e tests
- path: test/e2e/
linters:
- forbidigo
text: 'use apiclient.Client instead'
# Restrict krtequals analyzer to the pkg and internal directories
- path-except: pkg/|internal/
linters:
- krtequals
# Only run kubeapilinter inside the 'api/' directory. This prevents running API-specific checks
# on unrelated packages like controllers or tests and producing false positives.
- path-except: "^api/v1alpha1"
linters:
- kubeapilinter
issues:
max-same-issues: 0
uniq-by-line: true
formatters:
enable:
- gofumpt
- gci
settings:
gci:
sections:
- standard
- default
- prefix(github.com/kgateway-dev)
- blank
- dot
- localmodule
custom-order: true
exclusions:
generated: lax
paths:
- test/rules
- gomock_reflect_\d*
- third_party$
- builtin$
- examples$