-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.golangci.yml
More file actions
505 lines (505 loc) · 16.8 KB
/
Copy path.golangci.yml
File metadata and controls
505 lines (505 loc) · 16.8 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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
# Origin: https://github.com/powerman/golangci-lint-strict version 2.12.2
version: "2"
linters:
default: all
disable:
- containedctx # Questionable.
- contextcheck # Questionable.
- cyclop # Prefer gocognit.
- dogsled # Questionable (assignment to how many blank identifiers is not okay?).
- dupl
- forcetypeassert # Questionable (often we actually want panic).
- gocyclo # Prefer gocognit.
- gomodguard # Deprecated.
- interfacebloat # Questionable.
- ireturn # Questionable (is returning unexported types better?).
- lll # Questionable (sometimes long lines improve readability).
- nlreturn # Questionable (often no blank line before return improve readability).
- nonamedreturns # Questionable (named return act as a documentation).
- perfsprint # Questionable (force performance over readability and sometimes safety).
- varnamelen
- wrapcheck # Questionable (see https://github.com/tomarrell/wrapcheck/issues/1).
- wsl # Questionable (too much style differences, hard to consider).
- wsl_v5 # Questionable (too much style differences, hard to consider).
settings:
copyloopvar:
check-alias: true
decorder:
disable-init-func-first-check: false # `init` funcs have to be declared before all other functions.
depguard:
rules:
main:
deny:
- pkg: math/rand$
desc: use math/rand/v2
- pkg: github.com/prometheus/common/log
desc: Should be replaced by standard lib log/slog package
- pkg: github.com/sirupsen/logrus
desc: Should be replaced by standard lib log/slog package
- pkg: github.com/go-errors/errors
desc: Should be replaced by standard lib errors package
- pkg: github.com/pkg/errors
desc: Should be replaced by standard lib errors package
- pkg: github.com/prometheus/client_golang/prometheus/promauto
desc: Not allowed because it uses global variables
- pkg: github.com/golang/protobuf
desc: Should be replaced by google.golang.org/protobuf package
- pkg: github.com/grpc-ecosystem/go-grpc-middleware$
desc: Should be replaced by github.com/grpc-ecosystem/go-grpc-middleware/v2
- pkg: github.com/grpc-ecosystem/go-grpc-prometheus
desc: Should be replaced by github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus
no-test-libs-in-prod:
files:
- $all
- '!$test'
- '!**/*test/**'
- '!**/test*/**'
deny:
- pkg: testing
desc: test-only; production code must not import it
- pkg: github.com/powerman/check
desc: test-only; production code must not import it
- pkg: go.uber.org/mock/gomock
desc: test-only; production code must not import it
dupl:
threshold: 100
embeddedstructfieldcheck:
forbid-mutex: true
errcheck:
exclude-functions:
- encoding/json.Marshal # Required because of errchkjson.check-error-free-encoding.
- encoding/json.MarshalIndent # Required because of errchkjson.check-error-free-encoding.
errchkjson:
check-error-free-encoding: true
report-no-exported: true # Encoded struct must have exported fields.
exhaustive:
check:
- switch
- map
explicit-exhaustive-map: true # Only check maps with "//exhaustive:enforce" comment.
exhaustruct:
include:
- ^$ # Only check structs which domain.tld/package/name.structname match this regexp.
fatcontext:
check-struct-pointers: true
forbidigo:
forbid:
- pattern: ^print(ln)?$
exclude-godoc-examples: false
analyze-types: true
funcorder:
struct-method: false
gochecksumtype:
default-signifies-exhaustive: false
include-shared-interfaces: true
gocognit:
min-complexity: 20
gocritic:
enable-all: true
disabled-checks:
- exposedSyncMutex # Questionable.
- hugeParam # Premature optimization.
- paramTypeCombine # Questionable.
- switchTrue # Questionable.
- todoCommentWithoutDetail # Questionable.
- yodaStyleExpr # Questionable.
settings:
captLocal:
paramsOnly: false # Do not restrict checker to params only.
ruleguard:
failOn: all
truncateCmp:
skipArchDependent: false # Do not skip int/uint/uintptr types.
underef:
skipRecvDeref: false
unnamedResult:
checkExported: true
godoclint:
default: all
options:
max-len:
length: 97
godot:
exclude:
- :$ # Allow line followed by details in next line(s).
- '^\s*- ' # Allow line with a list item.
godox:
keywords:
- BUG # Marks issues that should be moved to issue tracker before merging.
- FIXME # Marks issues that should be resolved before merging.
- DEBUG # Marks temporary code that should be removed before merging.
gomodguard_v2:
blocked:
- module: github.com/cenkalti/backoff
version: < 4.0.0
reason: use actual version
gosec:
excludes:
- G104 # Audit errors not checked
config:
global:
audit: true
govet:
enable-all: true
disable:
- fieldalignment
settings:
shadow:
strict: true
grouper:
import-require-single-import: true # Use a single 'import' declaration.
iface:
enable:
- identical # Identifies interfaces in the same package that have identical method sets.
- unused # Identifies interfaces that are not used anywhere in the same package where the interface is defined.
- opaque # Identifies functions that return interfaces, but the actual returned value is always a single concrete implementation.
- unexported # Identifies interfaces that are not exported but are used in exported functions or methods.
importas:
no-unaliased: true
alias:
- pkg: errors
alias: ""
- pkg: net/url
alias: urlpkg
loggercheck:
require-string-key: true # Logging keys must be inlined constant strings.
no-printf-like: true
misspell:
mode: restricted # Check only comments.
nestif:
min-complexity: 4
nilnil:
only-two: false
detect-opposite: true
nolintlint:
require-explanation: true # Disable linters this way: //nolint:first,second // Reason here.
require-specific: true # Do not allow //nolint without specific linter name(s).
paralleltest:
check-cleanup: true
reassign:
patterns:
- .* # Check all global variables.
revive:
directives:
- name: specify-disable-reason
rules:
- name: add-constant
disabled: true # Duplicates goconst and mnd linters.
- name: argument-limit
disabled: true # Questionable.
- name: atomic
- name: banned-characters
arguments: [] # [ "Ω","Σ","σ", "7" ]
- name: bare-return
disabled: true # Questionable (in some cases bare return improves readability).
- name: blank-imports
- name: bool-literal-in-expr
- name: call-to-gc
- name: cognitive-complexity
disabled: true # Duplicates gocognit linter.
- name: comment-spacings
arguments:
- nolint # Allow //nolint without a space.
- name: comments-density
disabled: true # Questionable.
- name: confusing-naming
disabled: true # Questionable (valid use case: Method() as a thin wrapper for method()).
- name: confusing-results
- name: constant-logical-expr
- name: context-as-argument
arguments:
- allowTypesBefore: '*testing.T,*check.TB,*check.C' # Test helpers keep t first.
- name: context-keys-type
- name: cyclomatic
disabled: true # Duplicates cyclop and gocyclo linters.
- name: datarace
- name: deep-exit
- name: defer
- name: dot-imports
- name: duplicated-imports
- name: early-return
- name: empty-block
disabled: true # https://github.com/mgechev/revive/issues/386
- name: empty-lines
- name: enforce-map-style
arguments:
- make # Use `make(map[A]B)` instead of literal `map[A]B{}`.
- name: enforce-repeated-arg-type-style
disabled: true # Questionable (short form for similar args and full otherwise may improve readability).
- name: enforce-slice-style
disabled: true # Questionable (sometimes we need a nil slice, sometimes not nil).
- name: enforce-switch-style
arguments:
- allowNoDefault
- name: epoch-naming
- name: error-naming
- name: error-return
- name: error-strings
- name: errorf
- name: exported
disabled: true # Duplicates godoclint.
- name: file-header
- name: file-length-limit
- name: filename-format
- name: flag-parameter
- name: forbidden-call-in-wg-go
- name: function-length
disabled: true # Duplicates funlen linter.
- name: function-result-limit
disabled: true # Questionable.
- name: get-return
- name: identical-branches
- name: identical-ifelseif-branches
- name: identical-ifelseif-conditions
- name: identical-switch-branches
- name: identical-switch-conditions
- name: if-return
- name: import-alias-naming
- name: import-shadowing
- name: imports-blocklist
- name: increment-decrement
- name: indent-error-flow
- name: inefficient-map-lookup
- name: line-length-limit
disabled: true # Duplicates lll linter.
- name: max-control-nesting
- name: max-public-structs
disabled: true # Questionable.
- name: modifies-parameter
- name: modifies-value-receiver
- name: nested-structs
disabled: true # Questionable (useful in tests, may worth enabling for non-tests).
- name: optimize-operands-order
- name: package-comments
- name: package-directory-mismatch
- name: package-naming
- name: range
- name: range-val-address
- name: range-val-in-closure
- name: receiver-naming
- name: redefines-builtin-id
- name: redundant-build-tag
- name: redundant-import-alias
- name: redundant-test-main-exit
- name: string-format
arguments:
- - fmt.Errorf[0]
- /(^|[^\.!?])$/
- must not end in punctuation
- - panic
- /^[^\n]*$/
- must not contain line breaks
- name: string-of-int
- name: struct-tag
- name: superfluous-else
- name: time-date
- name: time-equal
- name: time-naming
- name: unchecked-type-assertion
disabled: true # Duplicates errcheck and forcetypeassert linters.
- name: unconditional-recursion
- name: unexported-naming
- name: unexported-return
- name: unhandled-error
disabled: true # Duplicates errcheck linter.
- name: unnecessary-format
- name: unnecessary-if
- name: unnecessary-stmt
- name: unreachable-code
- name: use-slices-sort
- name: unsecure-url-scheme
- name: unused-parameter
- name: unused-receiver
- name: use-any
- name: use-errors-new
- name: use-fmt-print
- name: use-slices-sort
- name: use-waitgroup-go
- name: useless-break
- name: useless-fallthrough
- name: var-declaration
- name: var-naming
- name: waitgroup-by-value
rowserrcheck:
packages:
- github.com/jmoiron/sqlx
- github.com/powerman/sqlxx
sloglint:
context: scope
static-msg: true
msg-style: capitalized
forbidden-keys:
- time # Used by standard slog.JSONHandler or slog.TextHandler.
- level # Used by standard slog.JSONHandler or slog.TextHandler.
- msg # Used by standard slog.JSONHandler or slog.TextHandler.
- source # Used by standard slog.JSONHandler or slog.TextHandler.
key-naming-case: snake
spancheck:
checks:
- end
- record-error
- set-status
staticcheck:
checks:
- all
- -ST1000 # Duplicates revive:package-comments.
- -ST1001 # Duplicates revive:dot-imports.
- -ST1003 # Duplicates revive:var-naming, revive:error-naming, revive:package-naming, revive:import-alias-naming.
- -ST1005 # Duplicates revive:string-format and revive:error-strings.
- -ST1006 # Duplicates revive:receiver-naming.
- -ST1008 # Duplicates revive:error-return.
- -ST1012 # Duplicates errname linter.
- -ST1016 # Duplicates revive:receiver-naming (consistency).
- -ST1019 # Duplicates revive:duplicated-imports.
- -ST1020 # Duplicates godoclint.
- -ST1021 # Duplicates godoclint.
- -ST1022 # Duplicates godoclint.
tagalign:
order:
- json
- yaml
- yml
- toml
- cmd
- arg
- embed
- hidden
- passthrough
- optional
- required
- default
- envprefix
- env
- name
- enum
- help
- mod
- mapstructure
- binding
- mold
- validate
strict: true
tagliatelle:
case:
rules:
json: snake
yaml: kebab
xml: camel
toml: camel
bson: camel
avro: snake
mapstructure: kebab
envconfig: upperSnake
whatever: snake
testifylint:
enable-all: true
testpackage:
skip-regexp: .*_internal_test\.go
thelper:
test:
name: false # Allow *testing.T param to have any name, not only `t`.
usestdlibvars:
time-date-month: true
time-month: true
time-layout: true
crypto-hash: true
default-rpc-path: true
sql-isolation-level: true
tls-signature-scheme: true
usetesting:
os-temp-dir: true
context-background: true
context-todo: true
unqueryvet:
check-tx-leaks: true
wrapcheck:
report-internal-errors: true
exclusions:
rules:
- linters:
- govet
text: declaration of "(log|err|ctx)" shadows
- path: _test\.go|testing(_.*)?\.go
linters:
- bodyclose
- dupl
- errcheck
- fatcontext
- forcetypeassert
- funlen
- gochecknoglobals
- gochecknoinits
- gocognit
- goconst
- godoclint
- gosec
- maintidx
- reassign
- path: _test\.go|testing(_.*)?\.go
text: (unnamedResult|exitAfterDefer|rangeValCopy|unnecessaryBlock)
linters:
- gocritic
- path: _test\.go
text: '"t" shadows'
linters:
- govet
- path: ^(.*/)?embed.go$
linters:
- gochecknoglobals
- source: '[Cc]onst' # Define global const-vars like: var SomeGlobal = []int{42} // Const.
linters:
- gochecknoglobals
- linters:
- lll
source: '^//go:generate '
- linters:
- staticcheck
text: 'SA5008: duplicate struct tag "set"' # Valid in Kong CLI.
- linters:
- godoclint
text: should have a godoc \("(String|Error|Format|(Marshal|Unmarshal)(Text|JSON))"\)
paths:
- \.[\w-]+\.go$ # Use this pattern to name auto-generated files.
formatters:
enable:
- gci
- gofmt
- gofumpt
- goimports
- golines
settings:
gci:
sections:
- standard # Standard section: captures all standard packages.
- default # Default section: contains all imports that could not be matched to another section type.
- localmodule # Local module section: contains all local packages. This section is not present unless explicitly enabled.
no-inline-comments: true
no-prefix-comments: true
gofmt:
rewrite-rules:
- pattern: interface{}
replacement: any
- pattern: a[b:len(a)]
replacement: a[b:]
golines:
max-len: 200
tab-len: 8
reformat-tags: false
exclusions:
generated: strict
paths:
- \.[\w-]+\.go$ # Use this pattern to name auto-generated files.
issues:
max-issues-per-linter: 0
max-same-issues: 0
output:
sort-order:
- linter
- severity
- file # filepath, line, and column.
show-stats: false
run:
timeout: 1m
modules-download-mode: readonly
severity:
default: error