forked from raystack/meteor
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.golangci-prod.toml
588 lines (496 loc) · 20.1 KB
/
.golangci-prod.toml
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
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
# Configuration for [email protected]
# See https://golangci-lint.run/usage/configuration/#config-file
# Options for analysis running
[run]
# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout = "10m"
# If set we pass it to "go list -mod={option}". From "go help modules":
# If invoked with -mod=readonly, the go command is disallowed from the implicit
# automatic updating of go.mod described above. Instead, it fails when any changes
# to go.mod are needed. This setting is most useful to check that go.mod does
# not need updates, such as in a continuous integration and testing system.
# If invoked with -mod=vendor, the go command assumes that the vendor
# directory holds the correct copies of dependencies and ignores
# the dependency descriptions in go.mod.
#
# Allowed values: readonly|vendor|mod
# By default, it isn't set.
modules-download-mode = "readonly"
# output configuration options
[output]
# Make issues output unique by line.
# Default: true
uniq-by-line = false
# See https://golangci-lint.run/usage/linters/
[linters]
# Disable-all coupled with enable scales well with updates to golangci-lint
disable-all = true
enable = [
# https://github.com/kisielk/errcheck
# errcheck is a program for checking for unchecked errors in Go code. These
# unchecked errors can be critical bugs in some cases.
"errcheck",
# https://github.com/dominikh/go-tools/tree/master/simple
# Linter for Go source code that specializes in simplifying code.
"gosimple",
# https://pkg.go.dev/cmd/vet
# Vet examines Go source code and reports suspicious constructs, such as
# Printf calls whose arguments do not align with the format string.
"govet",
# https://github.com/gordonklaus/ineffassign
# Detects when assignments to existing variables are not used.
"ineffassign",
# https://staticcheck.io/
# It's a set of rules from staticcheck. It's not the same thing as the
# staticcheck binary. The author of staticcheck doesn't support or approve
# the use of staticcheck as a library inside golangci-lint.
"staticcheck",
# https://github.com/dominikh/go-tools/tree/master/unused
# Checks Go code for unused constants, variables, functions and types.
"unused", # PROD only
# https://github.com/timakin/bodyclose
# checks whether HTTP response body is closed successfully.
# Disabled due to false positives from
# https://github.com/timakin/bodyclose/issues/30
# "bodyclose",
# https://github.com/mibk/dupl
# Tool for code clone detection.
"dupl",
# https://github.com/Antonboom/errname
# Checks that sentinel errors are prefixed with the Err and error types are
# suffixed with the Error.
"errname",
# https://github.com/polyfloyd/go-errorlint
# errorlint is a linter for that can be used to find code that will cause
# problems with the error wrapping scheme introduced in Go 1.13.
"errorlint",
# https://github.com/daixiang0/gci
# Gci controls Go package import order and makes it always deterministic.
"gci",
# https://github.com/leighmcculloch/gocheckcompilerdirectives
# Checks that go compiler directive comments (//go:) are valid.
"gocheckcompilerdirectives",
# https://github.com/uudashr/gocognit
# Computes and checks the cognitive complexity of functions.
"gocognit", # PROD only
# https://github.com/jgautheron/goconst
# Finds repeated strings that could be replaced by a constant.
"goconst",
# https://github.com/go-critic/go-critic
# Provides diagnostics that check for bugs, performance and style issues.
# Extensible without recompilation through dynamic rules. Dynamic rules are
# written declaratively with AST patterns, filters, report message and
# optional suggestion.
"gocritic", # PROD only
# https://github.com/mvdan/gofumpt
# Gofumpt checks whether code was gofumpt-ed.
"gofumpt",
# https://github.com/securego/gosec
# Inspects source code for security problems.
"gosec", # PROD only
# https://github.com/walle/lll
# Reports long lines.
"lll",
# https://github.com/client9/misspell
# Finds commonly misspelled English words in comments.
"misspell",
# https://github.com/junk1tm/musttag
# enforce field tags in (un)marshaled structs.
"musttag",
# https://github.com/alexkohler/nakedret
# Finds naked returns in functions greater than a specified function length.
"nakedret",
# https://github.com/gostaticanalysis/nilerr
# Finds the code that returns nil even if it checks that the error is not
# nil.
"nilerr",
# https://github.com/sonatard/noctx
# noctx finds sending http request without context.Context.
"noctx",
# https://github.com/golangci/golangci-lint/blob/master/pkg/golinters/nolintlint/README.md
# Reports ill-formed or insufficient nolint directives.
"nolintlint", # PROD only
# https://github.com/mgechev/revive
# Fast, configurable, extensible, flexible, and beautiful linter for Go.
# Drop-in replacement of golint.
"revive",
# https://github.com/jingyugao/rowserrcheck
# checks whether Err of rows is checked successfully.
"rowserrcheck",
# https://github.com/ryanrolds/sqlclosecheck
# Checks that sql.Rows and sql.Stmt are closed.
"sqlclosecheck",
# https://github.com/dominikh/go-tools/tree/master/stylecheck
# Stylecheck is a replacement for golint.
"stylecheck",
# https://github.com/sivchari/tenv
# tenv is analyzer that detects using os.Setenv instead of t.Setenv since
# Go1.17.
"tenv",
# https://github.com/maratori/testpackage
# linter that makes you use a separate _test package.
"testpackage",
# https://github.com/kulti/thelper
# thelper detects Go test helpers without t.Helper() call and checks the
# consistency of test helpers.
"thelper",
# https://github.com/mdempsky/unconvert
# Remove unnecessary type conversions.
"unconvert",
# https://github.com/sashamelentyev/usestdlibvars
# A linter that detect the possibility to use variables/constants from the
# Go standard library.
"usestdlibvars",
]
# All available settings of specific linters
[linters-settings]
[linters-settings.errcheck]
# Report about not checking of errors in type assertions: `a := b.(MyStruct)`.
# Such cases aren't reported by default.
# Default: false
check-type-assertions = true
[linters-settings.govet]
# Report about shadowed variables.
# Default: false
check-shadowing = true
# Enable all analyzers.
# Default: false
enable-all = true
# Disable analyzers by name
# See https://pkg.go.dev/golang.org/x/tools/go/analysis/passes#section-directories
disable = [
# (not needed) reports mismatches between assembly files and Go
# declarations.
"asmdecl",
# (dupl staticcheck) detects useless assignments.
"assign",
# (not needed) detects some violations of the cgo pointer passing rules.
"cgocall",
# (not needed) detects structs that would use less memory if their fields
# were sorted.
"fieldalignment",
# (not needed) serves as a trivial example and test of the Analysis API.
"findcall",
# (not needed) reports assembly code that clobbers the frame pointer
# before saving it.
"framepointer",
# (dupl revive struct-tag) defines an Analyzer that checks struct field
# tags are well formed.
"structtag",
]
[linters-settings.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.
]
[linters-settings.gocognit]
# Minimal code complexity to report.
# Default: 30 (but we recommend 10-20)
min-complexity = 20
[linters-settings.goconst]
# Ignore test files.
# Default: false
ignore-tests = true
[linters-settings.gocritic]
# Which checks should be enabled; can't be combined with 'disabled-checks'.
# See https://go-critic.github.io/overview#checks-overview.
# To check which checks are enabled run `GL_DEBUG=gocritic golangci-lint run`.
# By default, list of stable checks is used.
enabled-checks = [
# ============ Diagnostic ============
# https://go-critic.com/overview.html#checkers-from-the-diagnostic-group
# Detects suspicious arguments order.
"argOrder",
# Detects suspicious function calls.
"badCall",
# Detects suspicious condition expressions.
"badCond",
# Detects suspicious mutex lock/unlock operations.
"badLock",
# Detects erroneous case order inside switch statements.
"caseOrder",
# Detects commented-out code inside function bodies.
"commentedOutCode",
# Detects loops inside functions that use defer.
"deferInLoop",
# Detects malformed ‘deprecated’ doc-comments.
"deprecatedComment",
# Detects suspicious duplicated arguments.
"dupArg",
# Detects duplicated case clauses inside switch or select statements.
"dupCase",
# Detects calls to exit/fatal inside functions that use defer.
"exitAfterDefer",
# Detects problems in filepath.Join() function calls.
"filepathJoin",
# Detects suspicious map literal keys.
"mapKey",
# Detects various off-by-one kind of errors.
"offBy1",
# Detects suspicious http.Error call without following return.
"returnAfterHttpError",
# Detects suspicious/confusing re-assignments.
"sloppyReassign",
# Detects unsupported test and benchmark funcs.
"sloppyTestFuncName",
# Detects redundant type assertions.
"sloppyTypeAssert",
# Detects “%s” formatting directives that can be replaced with %q.
"sprintfQuotedString",
# Detects potential truncation issues when comparing ints of different
# sizes.
"truncateCmp",
# Detects conditions that are unsafe due to not being exhaustive.
"weakCond",
# ============ Style ============
# https://go-critic.com/overview.html#checkers-from-the-style-group
# Detects assignments that can be simplified by using assignment
# operators.
"assignOp",
# Detects bool expressions that can be simplified.
"boolExprSimplify",
# Detects commented-out imports.
"commentedOutImport",
# Detects else with nested if statement that can be replaced with else-if.
"elseif",
# Detects fallthrough that can be avoided by using multi case values.
"emptyFallthrough",
# Detects empty string checks that can be written more idiomatically.
"emptyStringTest",
# Detects repeated if-else statements and suggests to replace them with
# switch statement.
"ifElseChain",
# Finds where nesting level could be reduced.
"nestingReduce",
# Detects concatenation with os.PathSeparator which can be replaced with
# filepath.Join.
"preferFilepathJoin",
# Detects input and output parameters that have a type of pointer to
# referential type.
"ptrToRefParam",
# Detects redundant fmt.Sprint calls.
"redundantSprint",
# Detects regexp patterns that can be simplified.
"regexpSimplify",
# Detects strings.Compare usage.
"stringsCompare",
# Detects TODO comments without detail/assignee.
"todoCommentWithoutDetail",
# Detects dereference expressions that can be omitted.
"underef",
# Detects unnamed results that may benefit from names.
"unnamedResult",
# Detects slice expressions that can be simplified to sliced expression
# itself.
"unslice",
# Detects function calls that can be replaced with convenience wrappers.
"wrapperFunc",
# ============ Performance ============
# https://go-critic.com/overview.html#checkers-from-the-performance-group
# Detects fmt.Sprint(f/ln) calls which can be replaced with
# fmt.Fprint(f/ln).
"preferFprint",
# Detects w.Write or io.WriteString calls which can be replaced with
# w.WriteString.
"preferStringWriter",
# Detects loops that copy big objects during each iteration.
"rangeValCopy",
# Detects redundant conversions between string and []byte.
"stringXbytes",
]
# Settings passed to gocritic.
# The settings key is the name of a supported gocritic checker.
# The list of supported checkers can be found in https://go-critic.github.io/overview.
[linters-settings.gocritic.settings]
[linters-settings.gocritic.settings.underef]
# Whether to skip (*x).method() calls where x is a pointer receiver.
# Default: true
skipRecvDeref = false
[linters-settings.gocritic.settings.unnamedResult]
# Whether to check exported functions.
# Default: false
checkExported = true
[linters-settings.gocritic.settings.rangeValCopy]
# Size in bytes that makes the warning trigger.
# Default: 128
sizeThreshold = 512
[linters-settings.gofumpt]
# Choose whether to use the extra rules.
# Default: false
extra-rules = true
[linters-settings.gosec]
# To specify a set of rules to explicitly exclude.
# Available rules: https://github.com/securego/gosec#available-rules
# Default: []
excludes = [
# Look for hard coded credentials
# too many false positives
"G101"
]
[linters-settings.lll]
# Max line length, lines longer will be reported.
# '\t' is counted as 1 character by default, and can be changed with the tab-width option.
# Default: 120.
line-length = 160
[linters-settings.misspell]
# Correct spellings using locale preferences for US or UK.
# Default is to use a neutral variety of English.
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
locale = "US"
[linters-settings.nolintlint]
# Enable to require nolint directives to mention the specific linter being suppressed.
# Default: false
require-specific = true
[linters-settings.revive]
# Sets the default severity.
# See https://github.com/mgechev/revive#configuration
# Default: warning
severity = "error"
# Available rules - https://github.com/mgechev/revive/blob/v1.3.1/RULES_DESCRIPTIONS.md
[[linters-settings.revive.rules]]
# Reduces redundancies around variable declaration.
name = "var-declaration"
[[linters-settings.revive.rules]]
# Warns when a public return is from unexported type.
name = "unexported-return"
[[linters-settings.revive.rules]]
# Disallows blank imports.
name = "blank-imports"
[[linters-settings.revive.rules]]
# context.Context should be the first argument of a function.
name = "context-as-argument"
[[linters-settings.revive.rules]]
# Naming and commenting conventions on exported symbols.
name = "exported"
[[linters-settings.revive.rules]]
# Redundant if when returning an error.
name = "if-return"
[[linters-settings.revive.rules]]
# Use i++ and i-- instead of i += 1 and i -= 1.
name = "increment-decrement"
[[linters-settings.revive.rules]]
# Prevents redundant else statements.
name = "indent-error-flow"
[[linters-settings.revive.rules]]
# Specifies the maximum number of arguments a function can receive.
name = "argument-limit"
arguments = [5]
[[linters-settings.revive.rules]]
# Prevents redundant else statements (extends indent-error-flow).
name = "superfluous-else"
[[linters-settings.revive.rules]]
# Warns on methods with names that differ only by capitalization.
name = "confusing-naming"
[[linters-settings.revive.rules]]
# Looks for program exits in funcs other than main() or init().
name = "deep-exit"
[[linters-settings.revive.rules]]
# Suggests to rename or remove unused function parameters.
name = "unused-parameter"
[[linters-settings.revive.rules]]
# Checks common struct tags like json,xml,yaml.
name = "struct-tag"
[[linters-settings.revive.rules]]
# Warns on assignments to value-passed method receivers.
name = "modifies-value-receiver"
[[linters-settings.revive.rules]]
# Warns on constant logical expressions.
name = "constant-logical-expr"
[[linters-settings.revive.rules]]
# Warns on redefinitions of builtin identifiers.
name = "redefines-builtin-id"
[[linters-settings.revive.rules]]
# Specifies the maximum number of results a function can return.
name = "function-result-limit"
arguments = [3]
[[linters-settings.revive.rules]]
# Warns if address of range value is used dangerously.
name = "range-val-address"
[[linters-settings.revive.rules]]
# Warns on explicit call to the garbage collector.
name = "call-to-gc"
[[linters-settings.revive.rules]]
# Spots identifiers that shadow an import.
name = "import-shadowing"
[[linters-settings.revive.rules]]
# Warns on bare returns.
name = "bare-return"
[[linters-settings.revive.rules]]
# Suggests to rename or remove unused method receivers.
name = "unused-receiver"
[[linters-settings.revive.rules]]
# Spots if-then-else statements that can be refactored to simplify code
# reading.
name = "early-return"
[[linters-settings.revive.rules]]
# Warns on function calls that will lead to (direct) infinite recursion.
name = "unconditional-recursion"
[[linters-settings.revive.rules]]
# Spots if-then-else statements with identical then and else branches.
name = "identical-branches"
[[linters-settings.revive.rules]]
# Warns on some defer gotchas.
name = "defer"
[[linters-settings.revive.rules]]
# Warns on wrongly named un-exported symbols.
name = "unexported-naming"
[linters-settings.rowserrcheck]
# database/sql is always checked
# Default: []
packages = [
"github.com/jmoiron/sqlx",
]
[linters-settings.usestdlibvars]
# Suggest the use of http.StatusXX.
# covered by stylecheck ST1013.
# Default: true
http-status-code = false
# Suggest the use of time.Month.String().
# Default: false
time-month = true
# Suggest the use of time.Layout.
# Default: false
time-layout = true
# Suggest the use of sql.LevelXX.String().
# Default: false
sql-isolation-level = true
# Suggest the use of tls.SignatureScheme.String().
# Default: false
tls-signature-scheme = true
[issues]
# The list of ids of default excludes to include or disable.
# https://golangci-lint.run/usage/false-positives/#default-exclusions
# Default: []
include = [
# staticcheck SA4011: Break statement with no effect.
"EXC0005",
]
# Excluding configuration per-path, per-linter, per-text and per-source
[[issues.exclude-rules]]
text = 'declaration of "(err|ctx)" shadows declaration at'
linters = ["govet"]
[[issues.exclude-rules]]
path = "cmd/.*"
linters = ["dupl"]
[[issues.exclude-rules]]
# Exclude some linters from running on tests files.
path = "_test\\.go"
linters = [
"dupl",
"gosec",
"lll",
"gocognit",
"goconst",
]
[[issues.exclude-rules]]
linters = ["lll"]
source = "^//go:generate "
[[issues.exclude-rules]]
path = "_test\\.go"
text = "^Error return value is not checked$"
linters = ["errcheck"]