-
Notifications
You must be signed in to change notification settings - Fork 113
/
.golangci.yaml
481 lines (474 loc) · 17.3 KB
/
.golangci.yaml
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
## Golden config for golangci-lint v1.45.2
#
# This is the best config for golangci-lint based on my experience and opinion.
# It is very strict, but not extremely strict.
# Feel free to adopt and change it for your needs.
run:
timeout: 1m # default 1m
skip-dirs:
- ^client/
- ^cmd/ # TODO: fix lint
- ^pkg/raft/
- ^proto/
- ^test/ # TODO: fix lint
- ^tool/ # TODO: fix lint
severity:
default-severity: info
case-sensitive: false
rules:
- linters:
- contextcheck
severity: info
linters-settings:
errcheck:
disable-default-exclusions: false # disable built-in exclude list # default: false
check-type-assertions: true # default false
check-blank: false # default false
ignore: "fmt:.*" # default fmt:.*
exclude-functions: [] # see https://github.com/kisielk/errcheck#excluding-functions for details # default []
gosimple:
go: "1.16" # default 1.13
checks: ["*"] # https://staticcheck.io/docs/options#checks # default ["*"]
govet:
enable-all: true
disable:
- fieldalignment # too strict
settings:
shadow:
strict: true # default false
staticcheck:
go: "1.19" # default 1.13
checks: ["*"] # https://staticcheck.io/docs/options#checks # default ["*"]
unused:
check-exported: false # default false # TODO: enable after fixing false positives
bidichk:
# The following configurations check for all mentioned invisible unicode runes.
# All runes are enabled by default.
left-to-right-embedding: true # default true
right-to-left-embedding: true # default true
pop-directional-formatting: true # default true
left-to-right-override: true # default true
right-to-left-override: true # default true
left-to-right-isolate: true # default true
right-to-left-isolate: true # default true
first-strong-isolate: true # default true
pop-directional-isolate: true # default true
cyclop:
max-complexity: 30 # the maximal code complexity to report # default 10
package-average: 30.0 # the maximal average package complexity. If it's higher than 0.0 (float) the check is enabled # default 0.0
skip-tests: false # should ignore tests # default false
dupl:
threshold: 150 # default 150
errorlint:
# Check whether fmt.Errorf uses the %w verb for formatting errors. See the readme for caveats
errorf: true # default true
# Check for plain type assertions and type switches
asserts: true # default true
# Check for plain error comparisons
comparison: true # default true
exhaustive:
check-generated: false # indicates whether to check switch statements in generated Go source files # default false
default-signifies-exhaustive: false # if true, presence of "default" case in switch statements satisfies exhaustiveness, even if all enum members are not listed # default false
ignore-enum-members: "" # enum members matching the supplied regex do not have to be listed in switch statements to satisfy exhaustiveness # default ""
package-scope-only: false # consider enums only in package scopes, not in inner scopes # default false
forbidigo:
forbid: # forbid the following identifiers # default ^(fmt\.Print(|f|ln)|print|println)$
- ^(fmt\.Print(|f|ln)|print|println)$
exclude-godoc-examples: true # exclude godoc examples from forbidigo checks # default is true
funlen:
lines: 100 # default 60
statements: 80 # default 40
gocognit:
min-complexity: 80 # minimal code complexity to report, 30 by default (but we recommend 10-20)
goconst:
match-constant: true # look for existing constants matching the values # default true
min-len: 3 # minimal length of string constant # default 3
min-occurrences: 3 # minimum occurrences of constant string count to trigger issue # default 3
numbers: true # search also for duplicated numbers # default false
min: 3 # minimum value, only works with goconst.numbers # default 3
max: 3 # maximum value, only works with goconst.numbers # default 3
ignore-calls: true # ignore when constant is not used as function argument # default true
ignore-tests: false # ignore test files # default false
gocritic:
settings:
captLocal:
paramsOnly: false # whether to restrict checker to params only # default true
elseif:
skipBalanced: false # whether to skip balanced if-else pairs # default true
#hugeParam: # disabled by default
# sizeThreshold: 80 # size in bytes that makes the warning trigger # default 80
#nestingReduce: # disabled by default
# bodyWidth: 5 # min number of statements inside a branch to trigger a warning # default 5
#rangeExprCopy: # disabled by default
# sizeThreshold: 512 # size in bytes that makes the warning trigger # default 512
# skipTestFuncs: true # whether to check test functions # default true
#rangeValCopy: # disabled by default
# sizeThreshold: 128 # size in bytes that makes the warning trigger # default 128
# skipTestFuncs: true # whether to check test functions # default true
#ruleguard: # disabled by default
# rules: "" # path to a gorules file # default ""
#tooManyResultsChecker: # disabled by default
# maxResults: 5 # maximum number of results # default 5
#truncateCmp: # disabled by default
# skipArchDependent: true # whether to skip int/uint/uintptr types # default true
underef:
skipRecvDeref: false # whether to skip (*x).method() calls where x is a pointer receiver # default true
#unnamedResult: # disabled by default
# checkExported: false # whether to check exported functions # default false
gocyclo:
min-complexity: 30 # default 30
godot:
scope: declarations # comments to be checked: `declarations` (default), `toplevel`, or `all`
exclude: [] # list of regexps for excluding particular comment lines from check # default []
capital: false # check that each sentence starts with a capital letter # default false
period: true # check that each sentence ends with a period # default true
gomnd:
# List of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description.
checks: # default argument,case,condition,operation,return,assign
- argument
- case
- condition
- operation
- return
- assign
# List of numbers to exclude from analysis. The numbers should be written as string.
# Following values always ignored: "1", "1.0", "0" and "0.0"
ignored-numbers: [] # default []
# List of file patterns to exclude from analysis.
# Following values always ignored: `.+_test.go`
ignored-files: [] # default []
# List of function patterns to exclude from analysis.
# Following functions always ignored: `time.Date`
ignored-functions: [] # default []
gomoddirectives:
replace-allow-list: [] # list of allowed `replace` directives # default []
replace-local: false # allow local `replace` directives # default false
exclude-forbidden: false # forbid the use of `exclude` directives # default false
retract-allow-no-explanation: false # allow to use `retract` directives without explanation # default false
gomodguard:
allowed:
modules: [] # default []
domains: [] # default []
blocked:
modules:
- github.com/golang/protobuf:
recommendations:
- google.golang.org/protobuf
reason: "see https://developers.google.com/protocol-buffers/docs/reference/go/faq#modules"
- github.com/satori/go.uuid:
recommendations:
- github.com/google/uuid
reason: "satori's package is not maintained"
- github.com/gofrs/uuid:
recommendations:
- github.com/google/uuid
reason: "see recommendation from dev-infra team: https://confluence.gtforge.com/x/gQI6Aw"
versions: [] # default []
local_replace_directives: true # default false
lll:
line-length: 120 # default 120
makezero:
always: false # default false
maligned:
suggest-new: true # default false
misspell:
locale: us
ignore-words: "" # default: ""
nakedret:
max-func-lines: 0 # default 30
nestif:
min-complexity: 8 # default 5
nilnil:
checked-types: # default [ptr, func, iface, map, chan]
- ptr
- func
- iface
- map
- chan
nolintlint:
allow-unused: false # default false
allow-leading-space: true # default true
allow-no-explanation: [funlen, gocognit, lll] # default []
require-explanation: true # default false
require-specific: true # default false
prealloc:
simple: false # default true
range-loops: true # default true
for-loops: false # default false
predeclared:
ignore: "" # comma-separated list of predeclared identifiers to not report on # default ""
q: false # include method names and field names (i.e., qualified names) in checks # default false
promlinter:
# Promlinter cannot infer all metrics name in static analysis.
# Enable strict mode will also include the errors caused by failing to parse the args.
strict: false # default false
# Please refer to https://github.com/yeya24/promlinter#usage for detailed usage.
disabled-linters:
# - "Help"
# - "MetricUnits"
# - "Counter"
# - "HistogramSummaryReserved"
# - "MetricTypeInName"
# - "ReservedChars"
# - "CamelCase"
# - "lintUnitAbbreviations"
revive: # default rules are ignored if any of following settings is defined
#max-open-files: 0 # maximum number of open files at the same time # defaults 0 - unlimited
#ignore-generated-header: false # when set to false, ignores files with "GENERATED" header, similar to golint # default false
#confidence: 0.3 # default failure confidence, this means that linting errors with less than X confidence will be ignored # default 0.8
#severity: "warning" # minimal rule severity to fail {"error", "warning"} # default "warning"
#enable-all-rules: false # default false
# There is a list of default rules, but it can be redefined, see https://github.com/mgechev/revive#available-rules
#rules:
# - name: "xxx"
# disabled: false
# arguments: []
# severity: "xxx"
# allows to redefine rule severity (without changing default rules list)
#directives:
# - name: "xxx"
# severity: "xxx"
stylecheck:
go: "1.16" # default 1.13
checks: ["*"] # https://staticcheck.io/docs/options#checks # default ["*"]
dot-import-whitelist: [] # https://staticcheck.io/docs/options#dot_import_whitelist # default []
initialisms: [
"ACL",
"API",
"ASCII",
"CPU",
"CSS",
"DNS",
"EOF",
"GUID",
"HTML",
"HTTP",
"HTTPS",
"ID",
"IP",
"JSON",
"QPS",
"RAM",
"RPC",
"SLA",
"SMTP",
"SQL",
"SSH",
"TCP",
"TLS",
"TTL",
"UDP",
"UI",
"GID",
"UID",
"UUID",
"URI",
"URL",
"UTF8",
"VM",
"XML",
"XMPP",
"XSRF",
"XSS",
] # https://staticcheck.io/docs/options#initialisms
http-status-code-whitelist: ["200", "400", "404", "500"] # https://staticcheck.io/docs/options#http_status_code_whitelist
tenv:
all: true # check all functions in _test.go, not only test functions # default false
testpackage:
skip-regexp: (export|internal)_test\.go # default (export|internal)_test\.go
unparam:
check-exported: true # default false
wrapcheck:
ignoreSigs: [] # specifies substrings of signatures to ignore. Overrides default https://github.com/tomarrell/wrapcheck#configuration # default []
ignoreSigRegexps: [] # this is similar to the ignoreSigs, but gives slightly more flexibility # default []
ignorePackageGlobs: [] # see https://github.com/tomarrell/wrapcheck#configuration # default []
linters:
disable-all: true
enable:
## enabled by default
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- typecheck
- unused
## disabled by default
- asciicheck
- bidichk
- bodyclose
# - contextcheck
- cyclop
- dupl
- durationcheck
- errname
- errorlint
- exhaustive
- exportloopref
- funlen
- forbidigo
- gochecknoglobals
- gochecknoinits
- gocognit
- goconst
- gocritic
- gocyclo
- godot
- goimports
- gomnd
#- gomoddirectives
#- gomodguard
- goprintffuncname
- gosec
- lll
- makezero
- nakedret
- nestif
- nilerr
- nilnil
- noctx
- nolintlint
- prealloc
- predeclared
- promlinter
- revive
- stylecheck
- tenv
- tparallel
- unconvert
#- unparam
- whitespace
## disabled
#- wastedassign
#- testpackage
#- containedctx # is not used - linter that detects struct contained context.Context field
#- decorder # is not used - a declaration order and number linter for golang
#- depguard # replaced with gomodguard
#- dogsled # is not used - сhecks assignments with too many blank identifiers (e.g. x, _, _, _, := f())
#- errchkjson # is not used - checks types that are json encoded - reports unsupported types and unnecessary error checks
#- exhaustivestruct # too strict - finds structs that have uninitialized fields # TODO: maybe enable for some packages?
#- forcetypeassert # errcheck is used instead
#- gci # is not used - sorts imports
#- godox # is not used - complains about TODOs in comments
#- goerr113 # too strict - checks the errors handling expressions
#- gofmt # replaced with goimports
#- gofumpt # replaced with goimports, gofumports is not available yet
#- goheader # is not used - checks that each file has the licence at the beginning
#- golint # deprecated - revive is used instead
#- grouper # is not used - analyze expression groups, require 'import' declaration groups
#- ifshort # is not used - checks that your code uses short syntax for if-statements whenever possible
#- importas # is not used - enforces consistent import aliases
#- interfacer # deprecated and has false positives
#- ireturn # good, but too strict - accept interfaces, return concrete types
#- maintidx # is not used - measures the maintainability index of each function
#- maligned # deprecated
#- misspell # useless - correct commonly misspelled English words... quickly
#- nlreturn # too strict - requires a new line before return and branch statements
#- paralleltest # too many false positives
#- scopelint # deprecated
#- tagliatelle # is not used - checks the struct tags
#- thelper # is not used - requires to use t.Helper()
#- wrapcheck # too strict - requires wrapping errors from external packages (even from the same repo) and interfaces
#- varnamelen # great idea, but too many false positives - checking length of variable's name matches its usage scope
#- wsl # too strict - enforces empty lines at the right places
output:
uniq-by-line: false # default true
issues:
max-issues-per-linter: 0
max-same-issues: 0
exclude-rules:
- path: "worker.go"
linters:
- contextcheck
- text: "type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors"
linters:
- errorlint
- text: "switch on an error will fail on wrapped errors. Use errors.Is to check for specific errors"
linters:
- errorlint
- text: "missing cases in switch of type"
linters:
- exhaustive
- source: "strconv|make|len|math"
linters:
- gomnd
- path: "action"
linters:
- dupl
- path: "convert.go"
linters:
- dupl
- path: "_filter.go"
linters:
- dupl
- text: "^(G401|G404|G501)"
linters:
- gosec
- text: "(^shutdownHandler|^onlyOneSignalHandler)*."
linters:
- gochecknoglobals
- path: "util.go"
linters:
- gosec
- gomnd
- path: "init.go"
linters:
- gochecknoinits
- text: "unexported-return: exported func (NewController|NewGateway) returns unexported type"
linters:
- revive
- text: "Non-inherited new context"
linters:
- contextcheck
- text: "shadow: declaration of"
linters:
- govet
- source: "TODO"
linters:
- contextcheck
- source: "^//\\s*go:generate\\s"
linters:
- lll
- source: "(noinspection|TODO)"
linters:
- godot
- source: "//noinspection"
linters:
- gocritic
- source: "^\\s+if _, ok := err\\.\\([^.]+\\.InternalError\\); ok {"
linters:
- errorlint
- path: "errors\\.go"
linters:
- lll
- path: "_test\\.go"
linters:
- lll
- bodyclose
- dupl
- funlen
- goconst
- noctx
- wrapcheck
- errcheck
- contextcheck
- path: "ctrl_client.go"
linters:
- staticcheck
- contextcheck
- errorlint
- nestif
- revive
- gocritic
- source: FALLOC_FL_ZERO_RANGE
linters:
- revive
- stylecheck
- path: /testing/
linters:
- gomnd
- path: /testing/
source: \\. \"github.com/golang/mock/gomock\"||\\. \"github.com/smartystreets/goconvey/convey\"
linters:
- revive
- stylecheck