You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds
- pr-golangci-lint job
- exports GO_VERSION in the makefile that is used in other make targets
- updates .golangci.yml with CAPI changes, and also rebases CAPZ additions to it.
- update .golangci.yml
- ignore package comments across CAPZ
# declarations - for top level declaration comments (default);
110
-
# toplevel - for top level comments;
111
-
# all - for all comments.
112
-
scope: toplevel
113
-
exclude:
114
-
- '^ \+.*'
115
-
- '^ ANCHOR.*'
116
-
gosec:
117
-
excludes:
118
-
- G307# Deferring unsafe method "Close" on type "\*os.File"
119
-
- G108# Profiling endpoint is automatically exposed on /debug/pprof
139
+
nolintlint:
140
+
allow-unused: false
141
+
require-specific: true
120
142
revive:
121
143
rules:
144
+
# The following rules are recommended https://github.com/mgechev/revive#recommended-configuration
145
+
- name: blank-imports
146
+
- name: context-as-argument
147
+
- name: context-keys-type
148
+
- name: dot-imports
149
+
- name: error-return
150
+
- name: error-strings
151
+
- name: error-naming
152
+
- name: if-return
153
+
- name: increment-decrement
154
+
- name: var-naming
155
+
- name: var-declaration
156
+
- name: package-comments
157
+
- name: range
158
+
- name: receiver-naming
159
+
- name: time-naming
160
+
- name: unexported-return
161
+
- name: indent-error-flow
162
+
- name: errorf
163
+
- name: empty-block
164
+
- name: superfluous-else
165
+
- name: unused-parameter
166
+
- name: unreachable-code
167
+
- name: redefines-builtin-id
168
+
#
169
+
# Rules in addition to the recommended configuration above.
170
+
#
171
+
- name: bool-literal-in-expr
172
+
- name: constant-logical-expr
122
173
- name: exported
123
174
arguments:
124
175
- disableStutteringCheck
125
-
staticcheck:
126
-
go: "1.22"
127
-
stylecheck:
128
-
go: "1.22"
129
176
unused:
130
177
go: "1.22"
131
178
132
179
issues:
180
+
exclude-files:
181
+
- 'zz_generated\.(\w*)\.go$'
133
182
exclude-rules:
134
183
- path: '(\w*)conversion.go'
135
184
text: "use underscores in Go names|receiver name (.+) should be consistent|methods on the same type should have the same receiver name"
@@ -145,8 +194,114 @@ issues:
145
194
text: exported (.+) should have comment( \(or a comment on this block\))? or be unexported
146
195
- source: \"github.com/onsi/(ginkgo/v2|gomega)\"
147
196
text: "should not use dot imports"
148
-
include:
149
-
- EXC0012 # revive: check for comments
150
-
- EXC0014 # revive: check for comments
197
+
# Exclude some packages or code to require comments, for example test code, or fake clients.
198
+
- linters:
199
+
- revive
200
+
text: exported (method|function|type|const) (.+) should have comment or be unexported
201
+
source: (func|type).*Fake.*
202
+
- linters:
203
+
- revive
204
+
text: exported (method|function|type|const) (.+) should have comment or be unexported
205
+
path: fake_\.go
206
+
# Dot imports for gomega and ginkgo are allowed
207
+
# within test files and test utils.
208
+
- linters:
209
+
- revive
210
+
- stylecheck
211
+
path: _test\.go
212
+
text: should not use dot imports
213
+
- linters:
214
+
- revive
215
+
# Checking if an error is nil to just after return the error or nil is redundant
216
+
text: "if-return: redundant if ...; err != nil check, just return error instead"
217
+
# Ignoring stylistic checks for generated code
218
+
path: .*(api|types|test)\/.*\/conversion.*\.go$
219
+
- linters:
220
+
- revive
221
+
# Exported function and methods should have comments. This warns on undocumented exported functions and methods.
222
+
text: exported (method|function|type|const) (.+) should have comment or be unexported
223
+
# Ignoring stylistic checks for generated code
224
+
path: .*(api|types|test)\/.*\/conversion.*\.go$
225
+
- linters:
226
+
- revive
227
+
# By convention, receiver names in a method should reflect their identity.
228
+
text: "receiver-naming: receiver name"
229
+
# Ignoring stylistic checks for generated code
230
+
path: .*(api|types)\/.*\/conversion.*\.go$
231
+
- linters:
232
+
- stylecheck
233
+
text: "ST1016: methods on the same type should have the same receiver name"
234
+
path: .*(api|types)\/.*\/conversion.*\.go$
235
+
# We don't care about defer in for loops in test files.
236
+
- linters:
237
+
- gocritic
238
+
text: "deferInLoop: Possible resource leak, 'defer' is called in the 'for' loop"
239
+
path: _test\.go
240
+
# Ignore non-constant format string in call to condition utils
241
+
- linters:
242
+
- govet
243
+
text: "non-constant format string in call to sigs\\.k8s\\.io\\/cluster-api\\/util\\/conditions\\."
244
+
# for i = x; i < y; i++ {} is already optimal; Ignore this linter message
245
+
- linters:
246
+
- intrange
247
+
text: "for loop can be changed to use an integer range"
248
+
# Ignore the return value of below functions in test files
249
+
- linters:
250
+
- errcheck
251
+
text: Error return value of (`os.Setenv`|`fmt.Fprintf`|`resp.Body.Close`|`os.Unsetenv`|`fmt.Fprintln`|`[\w\.]+\.Close`|`[\w\.]+\.Flush`|`[\w\.]+\.RemoveAll`) is not checked
252
+
path: (^test\/e2e\/.*\.go$|.*_test\.go$)
253
+
# Do not validate file paths in tests
254
+
- linters:
255
+
- gosec
256
+
text: "G304: Potential file inclusion via variable"
257
+
path: ^test\/e2e\/.*\.go$
258
+
# Ignore the elevated access that "others" have for dirs/files created in tests with 0755 permissions
259
+
- linters:
260
+
- gosec
261
+
text: "G301: Expect directory permissions to be 0750 or less"
262
+
path: ^test\/e2e\/.*\.go$
263
+
# Ignore the elevated access that "group" and "others" have for dirs/files opened in tests with 0644 permissions
264
+
- linters:
265
+
- gosec
266
+
text: "G302: Expect file permissions to be 0600 or less"
267
+
path: ^test\/e2e\/.*\.go$
268
+
# Ignore unhandled errors in test files when using os.Setenv
269
+
- linters:
270
+
- gosec
271
+
text: "G104: Errors unhandled."
272
+
path: ^test\/e2e\/.*\.go$
273
+
# Ignore the unhandled errors on using os.Setenv in test files
274
+
- linters:
275
+
- gosec
276
+
text: "G104: Errors unhandled."
277
+
path: .*_test\.go$
278
+
# Ignore unused parameters in test files
279
+
- linters:
280
+
- revive
281
+
text: "^unused-parameter: parameter '.*' seems to be unused, consider removing or renaming it as _$"
282
+
path: .*(_test|test)\.go$
283
+
# Ignore adding package comments for all files. TODO: Ideally, we should add package comments to all the packages files.
284
+
- linters:
285
+
- revive
286
+
text: "^package-comments: package comment should be of the form \".*\"$"
287
+
path: .*\.go$
288
+
# Ignore adding package comments for all files. TODO: Ideally, we should add package comments to all the packages files.
289
+
- linters:
290
+
- revive
291
+
text: "package-comments: should have a package comment"
292
+
path: .*\.go$
293
+
# Ignore adding package comments for all files. TODO: Ideally, we should add package comments to all the packages files.
294
+
- linters:
295
+
- stylecheck
296
+
text: "ST1000: at least one file in a package should have a package comment"
297
+
path: .*\.go$
298
+
# Ignore adding package comments for all files. TODO: Ideally, we should add package comments to all the packages files.
299
+
- linters:
300
+
- stylecheck
301
+
text: "ST1000: package comment should be of the form \".*\"$"
302
+
path: .*\.go$
303
+
# We are disabling default golangci exclusions because we want to help reviewers to focus on reviewing the most relevant
0 commit comments