-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy path.golangci.yml
362 lines (362 loc) · 11.7 KB
/
.golangci.yml
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
# Origin: https://github.com/powerman/golangci-lint-strict version 1.61.0
run:
modules-download-mode: readonly
output:
sort-results: true
sort-order:
- linter
- severity
- file # Filepath, line, and column.
linters-settings:
decorder:
disable-init-func-first-check: false # `init` funcs have to be declared before all other functions.
depguard:
rules:
main:
deny:
- 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
dupl:
threshold: 100 # Tokens.
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.
forbidigo:
forbid:
- ^print(ln)?$
exclude-godoc-examples: false
analyze-types: true
funlen:
ignore-comments: true
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.
gocognit:
min-complexity: 20
goconst:
ignore-tests: true
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
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.
gofmt:
rewrite-rules:
- pattern: interface{}
replacement: any
- pattern: a[b:len(a)]
replacement: a[b:]
gomodguard:
blocked:
versions:
- github.com/cenkalti/backoff:
version: < 4.0.0
reason: use actual version
gosec:
excludes:
- G104 # Audit errors not checked
exclude-generated: true
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.
importas:
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
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:
ignore-missing: true # Do not require `t.Parallel()` everywhere.
ignore-missing-subtests: true # Do not require `t.Parallel()` in all subtests.
reassign:
patterns:
- .* # Check all global variables.
revive:
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
- 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: error-naming
- name: error-return
- name: error-strings
- name: errorf
- name: exported
- name: file-header
- name: flag-parameter
- name: function-length
disabled: true # Duplicates funlen linter.
- name: function-result-limit
disabled: true # Questionable.
- name: get-return
- name: identical-branches
- name: if-return
- name: import-alias-naming
- name: import-shadowing
- name: imports-blocklist
- name: increment-decrement
- name: indent-error-flow
- 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: range
- name: range-val-address
- name: range-val-in-closure
- name: receiver-naming
- name: redefines-builtin-id
- name: redundant-import-alias
- 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-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-stmt
- name: unreachable-code
- name: unused-parameter
- name: unused-receiver
- name: use-any
- name: useless-break
- 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
key-naming-case: snake
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.
tagalign:
order:
- json
- yaml
- yml
- toml
- env
- mod
- mapstructure
- binding
- validate
strict: true
tagliatelle:
case:
use-field-name: true
rules:
json: snake
yaml: kebab
xml: camel
toml: camel
bson: camel
avro: snake
mapstructure: kebab
envconfig: upperSnake
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-weekday: true
time-month: true
time-layout: true
crypto-hash: true
default-rpc-path: true
sql-isolation-level: true
tls-signature-scheme: true
linters:
enable-all: true
disable:
- containedctx # Questionable.
- contextcheck # Questionable.
- cyclop # Prefer gocognit.
- dogsled # Questionable (assignment to how many blank identifiers is not okay?).
- dupl
- execinquery # Deprecated.
- exportloopref # Deprecated.
- forcetypeassert # Questionable (often we actually want panic).
- gocyclo # Prefer gocognit.
- gomnd # 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).
issues:
exclude:
- declaration of "(log|err|ctx)" shadows
- 'missing cases in switch of type \S+: \S+_UNSPECIFIED$'
exclude-rules:
- path: _test\.go|testing(_.*)?\.go
linters:
- bodyclose
- dupl
- errcheck
- forcetypeassert
- funlen
- gochecknoglobals
- gochecknoinits
- gocognit
- goconst
- gosec
- maintidx
- reassign
- source: const # Define global const-vars like: var SomeGlobal = []int{42} // Const.
linters:
- gochecknoglobals
- 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
exclude-use-default: false # Disable default exclude patterns.
exclude-files:
- \.[\w-]+\.go$ # Use this pattern to name auto-generated files.
max-issues-per-linter: 0
max-same-issues: 0
severity:
default-severity: error