-
Notifications
You must be signed in to change notification settings - Fork 0
/
.golangci.yml
408 lines (386 loc) · 11.8 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
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
# Code generated by craft; DO NOT EDIT.
# all available settings of specific linters
linters-settings:
cyclop:
# The maximal code complexity to report.
# Default: 10
max-complexity: 20
decorder:
# Required order of `type`, `const`, `var` and `func` declarations inside a file.
# Default: types before constants before variables before functions.
dec-order:
- const
- var
- type
- func
# If true, order of declarations is not checked at all.
# Default: true (disabled)
disable-dec-order-check: true
# If true, `init` func can be anywhere in file (does not have to be declared before all other functions).
# Default: true (disabled)
disable-init-func-first-check: true
errcheck:
# report about not checking of errors in type assetions: `a := b.(MyStruct)`;
# default is false: such cases aren't reported by default.
check-type-assertions: true
funlen:
# Checks the number of lines in a function.
# If lower than 0, disable the check.
# Default: 60
lines: 80
# Checks the number of statements in a function.
# If lower than 0, disable the check.
# Default: 40
statements: 60
# Ignore comments when counting lines.
# Default false
ignore-comments: true
gci:
# Section configuration to compare against.
# Section names are case-insensitive and may contain parameters in ().
# The default order of sections is `standard > default > custom > blank > dot`,
# If `custom-order` is `true`, it follows the order of `sections` option.
# Default: ["standard", "default"]
sections:
- standard # Standard section: captures all standard packages.
- default # Default section: contains all imports that could not be matched to another section type.
- prefix(github.com/kilianpaquier/pooling) # Custom section: groups all imports with the specified Prefix.
gocognit:
# Minimal code complexity to report.
# Default: 30 (but we recommend 10-20)
min-complexity: 30
gosec:
# Exclude generated files
# Default: false
exclude-generated: true
govet:
# Enable all analyzers.
# Default: false
enable-all: true
# Disable analyzers by name.
# (in addition to default
# atomicalign, deepequalerrors, fieldalignment, findcall, nilness, reflectvaluecompare, shadow, sortslice,
# timeformat, unusedwrite
# ).
# Run `go tool vet help` to see all analyzers.
# Default: []
disable:
- fieldalignment
- shadow
misspell:
# Correct spellings using locale preferences for US or UK.
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
# Default is to use a neutral variety of English.
locale: US
# Default: []
ignore-words: []
nonamedreturns:
# Report named error if it is assigned inside defer.
# Default: false
report-error-in-defer: true
paralleltest:
# Ignore missing calls to `t.Parallel()` and only report incorrect uses of it.
# Default: false
ignore-missing: true
# Ignore missing calls to `t.Parallel()` in subtests. Top-level tests are
# still required to have `t.Parallel`, but subtests are allowed to skip it.
# Default: false
ignore-missing-subtests: true
perfsprint:
# Optimizes even if it requires an int or uint type cast.
# Default: true
int-conversion: true
# Optimizes into `err.Error()` even if it is only equivalent for non-nil errors.
# Default: false
err-error: true
# Optimizes `fmt.Errorf`.
# Default: true
errorf: true
# Optimizes `fmt.Sprintf` with only one argument
# Default: true
sprintf1: true
prealloc:
# IMPORTANT: we don't recommend using this linter before doing performance profiling.
# For most programs usage of prealloc will be a premature optimization.
# Report pre-allocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
# Default: true
simple: true
# Report pre-allocation suggestions on range loops.
# Default: true
range-loops: true
# Report pre-allocation suggestions on for loops.
# Default: false
for-loops: true
revive:
# Sets the default severity.
# See https://github.com/mgechev/revive#configuration
# Default: warning
severity: error
# Sets the default failure confidence.
# This means that linting errors with less than 0.8 confidence will be ignored.
# Default: 0.8
confidence: 0.1
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md
rules:
- name: argument-limit
arguments: [6]
- name: atomic
- name: blank-imports
- name: bool-literal-in-expr
- name: call-to-gc
- name: comment-spacings
- name: confusing-naming
- name: confusing-results
- name: constant-logical-expr
- name: context-as-argument
- name: context-keys-type
- name: datarace
- name: deep-exit
- name: defer
- name: dot-imports
- name: duplicated-imports
- name: early-return
- name: empty-block
- name: empty-lines
- name: enforce-map-style
arguments:
- literal
- name: error-naming
- name: error-return
- name: error-strings
- name: errorf
- name: exported
arguments:
- checkPrivateReceivers
- sayRepetitiveInsteadOfStutters
- name: flag-parameter
- name: function-result-limit
arguments: [3]
- name: get-return
- name: identical-branches
- name: if-return
- name: increment-decrement
- name: indent-error-flow
- name: import-alias-naming
arguments:
- "^[a-z_][a-z_0-9]{0,}$"
- name: imports-blocklist
- name: import-shadowing
- name: max-public-structs
arguments: [8]
- name: modifies-parameter
- name: modifies-value-receiver
- name: optimize-operands-order
# - name: package-comments
- name: range
- name: range-val-in-closure
- name: range-val-address
- name: receiver-naming
- name: redundant-import-alias
- name: redefines-builtin-id
- name: string-of-int
- name: string-format
arguments:
- - 'fmt.Errorf[0]'
- '/^([^A-Z]|$)/'
- must not start with a capital letter
- - 'fmt.Errorf[0]'
- '/(^|[^\.!?])$/'
- must not end in punctuation
- - panic
- '/^[^\n]*$/'
- must not contain line breaks
- name: struct-tag
- name: superfluous-else
- name: time-equal
- name: time-naming
- name: var-naming
arguments:
- [] # AllowList
- [] # DenyList
- - upperCaseConst: true # allow const variables to be uppercase
- name: var-naming
arguments:
- [] # AllowList
- [] # DenyList
- - skipPackageNameChecks: true # allow packages name with "_"
- name: var-declaration
- name: unconditional-recursion
- name: unexported-naming
- name: unexported-return
- name: unhandled-error
arguments:
- bytes.Buffer.Write.*
- fmt.Print
- fmt.Printf
- fmt.Println
- name: unnecessary-stmt
- name: unreachable-code
- name: unused-parameter
arguments:
- allowRegex: "^_"
- name: unused-receiver
arguments:
- allowRegex: "^_"
- name: useless-break
- name: waitgroup-by-value
tagalign:
# Specify the order of tags, the other tags will be sorted by name.
# This option will be ignored if `sort` is false.
# Default: []
order:
- json
- yaml
- yml
- toml
- mapstructure
- binding
- builder
- validate
# Whether enable strict style.
# In this style, the tags will be sorted and aligned in the dictionary order,
# and the tags with the same name will be aligned together.
# Note: This option will be ignored if 'align' or 'sort' is false.
# Default: false
strict: true
testifylint:
require-error:
# Regexp for assertions to analyze. If defined, then only matched error assertions will be reported.
# Default: ""
fn-pattern: ^NoErrorf?$
varnamelen:
# The longest distance, in source lines, that is being considered a "small scope".
# Variables used in at most this many lines will be ignored.
# Default: 5
max-distance: 10
# The minimum length of a variable's name that is considered "long".
# Variable names that are at least this long will be ignored.
# Default: 3
min-name-length: 2
# Optional list of variable declarations that should be ignored completely.
# Entries must be in one of the following forms (see below for examples):
# - for variables, parameters, named return values, method receivers, or type parameters:
# <name> <type> (<type> can also be a pointer/slice/map/chan/...)
# - for constants: const <name>
#
# Default: []
ignore-decls:
- o options
- T any
- t testing.T
whitespace:
# Enforces newlines (or comments) after every multi-line if statement.
# Default: false
multi-if: true
# Enforces newlines (or comments) after every multi-line function signature.
# Default: false
multi-func: true
issues:
include:
# revive:exported enforce revive comments on exported types
- EXC0012 # exported (.+) should have comment( \(or a comment on this block\))? or be unexported
- EXC0014 # comment on exported (.+) should be of the form "(.+)..."
# revive:package-comments enforce revive comments on packages
# - EXC0013 # package comment should be of the form "(.+)...
# - EXC0015 # should have a package comment
exclude:
- G303 # file creation in shared tmp directory without using os.CreateTemp
- G306 # Expect WriteFile permissions to be 0600 or less
- ST1003 # already covered by revive var-naming linter (package naming constraints)
exclude-rules:
# disable funlen for all _test.go files
- path: _test.go
linters:
- dupl
- funlen
- goconst
- maintidx
# Maximum issues count per one linter.
# Set to 0 to disable.
# Default: 50
max-issues-per-linter: 0
# Maximum count of issues with the same text.
# Set to 0 to disable.
# Default: 3
max-same-issues: 0
linters:
# please, do not use `enable-all`: it's deprecated and will be removed soon.
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
disable-all: true
enable:
- asasalint
- bodyclose
- canonicalheader
- containedctx
- contextcheck
- copyloopvar
- cyclop
- decorder
- dogsled
- dupl
- durationcheck
- errcheck
- errname
- errorlint
- exhaustive
- fatcontext
- forbidigo
- forcetypeassert
- funlen
- gci
- gocheckcompilerdirectives
- gocognit
- goconst
- gocritic
- gocyclo
- godox
- gofumpt
- goprintffuncname
- gosec
- gosimple
- govet
- grouper
- importas
- inamedparam
- ineffassign
- interfacebloat
- intrange
- maintidx
- makezero
- mirror
- misspell
- musttag
- nakedret
- nestif
- nilerr
- nilnil
- noctx
- nolintlint
- nosprintfhostport
- paralleltest
- perfsprint
- prealloc
- predeclared
- reassign
- revive
- rowserrcheck
- sloglint
- spancheck
- sqlclosecheck
- staticcheck
- stylecheck
- tagalign
- tenv
- testableexamples
- testifylint
- testpackage
- thelper
- tparallel
- typecheck
- unconvert
- unused
- usestdlibvars
- varnamelen
- wastedassign
- whitespace
- wrapcheck