-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.golangci.yml
479 lines (458 loc) · 18.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
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
# Options for analysis running.
run:
# Default concurrency is a available CPU number.
concurrency: 4
# Timeout for analysis. e.g. 30s, default is 1m.
deadline: 2m
# Exit code when at least one issue was found, default is 1.
issues-exit-code: 10
# Include test files, default is true.
tests: true
# Output configuration options.
output:
# Output styling.
# e.g. colored-line-number, line-number, json, tab, checkstyle, code-climate.
# Default is colored-line-number.
formats: colored-line-number
# Print lines of code with issue, default is true.
print-issued-lines: true
# Print linter name in the end of issue text, default is true.
print-linter-name: true
# List of enabled linters.
linters:
enable:
# Check for pass []any as any in variadic func(...any).
- asasalint
# Simple linter to check that your code does not contain non-ASCII identifiers.
- asciicheck
# Checks for non-printable characters in strings.
- bidichk
# Checks for missing semicolons.
- bodyclose
# Uheck whether the function uses a non-inherited context.
- contextcheck
# Go linter that checks if package imports are in a list of acceptable packages.
# - depguard
# checks for duplicate words in the source code [fast: true, auto-fix: true]
- dupword
# Tool for code clone detection.
- dupl
# Check for two durations multiplied together.
- durationcheck
# The errcheck is a program for checking for unchecked errors in Go code.
- errcheck
# Checks types passed to the json encoding functions. Reports unsupported types and optionally reports occasions, where the check for the returned error can be omitted.
- errchkjson
# The 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
# execinquery is a linter about query string checker in Query function which reads your Go src files and warning it finds.
- execinquery
# Check exhaustiveness of enum switch statements.
- exhaustive
# Checks for pointers to enclosing loop variables.
- exportloopref
# Finds forced type assertions.
- forcetypeassert
# Tool for detection of long functions.
- funlen
# Gci controls Go package import order and makes it always deterministic.
# - gci
# Enforces standards of using ginkgo and gomega.
- ginkgolinter
# Checks that go compiler directive comments (//go:) are valid.
- gocheckcompilerdirectives
# Check that no global variables.
# - gochecknoglobals
# Checks that no init functions are present in Go code.
# - gochecknoinits
# Finds repeated strings that could be replaced by a constant.
- goconst
# Provides diagnostics that check for bugs, performance and style issues.
- gocritic
# Computes and checks the cyclomatic complexity of functions.
- gocyclo
# Check if comments end in a period
# - godot
# Tool for detection of FIX.ME, TO.DO and other comment keywords.
# - godox
# Go linter to check the errors handling expressions.
- goerr113
# Check import statements are formatted according to the 'goimport' command. Reformat imports in autofix mode.
- goimports
# An analyzer to detect magic numbers.
- gomnd
# Checks that printf-like functions are named with f at the end.
- goprintffuncname
# Inspects source code for security problems.
- gosec
# Linter for Go source code that specializes in simplifying code.
- gosimple
# Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string.
- govet
# An analyzer to analyze expression groups.
- grouper
# Enforces consistent import aliases.
- importas
# A linter that checks the number of methods inside an interface.
- interfacebloat
# Accept Interfaces, Return Concrete Types.
- lll
# Checks key value pairs for common logger libraries (kitlog,klog,logr,zap).
- loggercheck
# Inds slice declarations with non-zero initial length
- makezero
# The mirror suggests use of alternative functions/methods in order to gain performance boosts by avoiding unnecessary []byte/string conversion calls
# - mirror
# Finds commonly misspelled English words in comments.
- misspell
# Enforce field tags in (un)marshaled structs.
- musttag
# Finds naked returns in functions greater than a specified function length.
- nakedret
# Reports deeply nested if statements.
- nestif
# Finds the code that returns nil even if it checks that the error is not nil.
- nilerr
# Checks that there is no simultaneous return of nil error and an invalid value.
- nilnil
# The nlreturn checks for a new line before return and branch statements to increase code clarity.
# - nlreturn
# The noctx finds sending http request without context.Context.
- noctx
# Reports ill-formed or insufficient nolint directives.
- nolintlint
# Checks for misuse of Sprintf to construct a host with port in a URL.
- nosprintfhostport
# The paralleltest detects missing usage of t.Parallel() method in your Go test
# - paralleltest
# Finds slice declarations that could potentially be pre-allocated.
- prealloc
# Find code that shadows one of Go's predeclared identifiers.
- predeclared
# Check Prometheus metrics naming via promlint.
- promlinter
# Checks that package variables are not reassigned.
- reassign
# Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint.
- revive
# Checks whether Err of rows is checked successfully.
- rowserrcheck
# Checks that sql.Rows and sql.Stmt are closed.
- sqlclosecheck
# 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
# Stylecheck is a replacement for golint.
- stylecheck
# The tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17
- tenv
# Like the front-end of a Go compiler, parses and type-checks Go code.
- typecheck
# The thelper detects Go test helpers without t.Helper() call and checks the consistency of test helpers.
- thelper
# Remove unnecessary type conversions.
- unconvert
# A linter that detect the possibility to use variables/constants from the Go standard library.
- usestdlibvars
# Checks Go code for unused constants, variables, functions and types.
# - unused
# The wastedassign finds wasted assignment statements.
# - wastedassign
# Tool for detection of leading and trailing whitespace.
- whitespace
# Whitespace Linter - Forces you to use empty lines!
- wsl
fast: false
# All available settings of specific linters.
linters-settings:
# Check for pass []any as any in variadic func(...any).
asasalint:
# To specify a set of function names to exclude.
# The values are merged with the builtin exclusions.
# The builtin exclusions can be disabled by setting `use-builtin-exclusions` to `false`.
# Default: ["^(fmt|log|logger|t|)\.(Print|Fprint|Sprint|Fatal|Panic|Error|Warn|Warning|Info|Debug|Log)(|f|ln)$"]
# exclude:
# - Append
# - \.Wrapf
# To enable/disable the asasalint builtin exclusions of function names.
# See the default value of `exclude` to get the builtin exclusions.
# Default: true
use-builtin-exclusions: true
# Ignore *_test.go files.
# Default: false
ignore-test: false
# Go linter that checks if package imports are in a list of acceptable packages [fast: true, auto-fix: false]
depguard:
# Rules to apply.
#
# Variables:
# - File Variables
# you can still use and exclamation mark ! in front of a variable to say not to use it.
# Example !$test will match any file that is not a go test file.
#
# `$all` - matches all go files
# `$test` - matches all go test files
#
# - Package Variables
#
# `$gostd` - matches all of go's standard library (Pulled from `GOROOT`)
#
# Default: no rules.
rules:
# # Name of a rule.
# main:
# # List of file globs that will match this list of settings to compare against.
# # Default: $all
# files:
# - "!**/*_a _file.go"
# # List of allowed packages.
# allow:
# - $gostd
# - github.com/OpenPeeDeeP
# # Packages that are not allowed where the value is a suggestion.
# deny:
# - pkg: "github.com/sirupsen/logrus"
# desc: not allowed
# - pkg: "github.com/pkg/errors"
# desc: Should be replaced by standard lib errors package
# The errcheck is a program for checking for unchecked errors in Go code. These unchecked errors can be critical bugs in some cases.
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: false
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`.
# Such cases aren't reported by default.
# Default: false
check-blank: true
# To disable the errcheck built-in exclude list.
# See `-excludeonly` option in https://github.com/kisielk/errcheck#excluding-functions for details.
# Default: false
disable-default-exclusions: false
# List of functions to exclude from checking, where each entry is a single function to exclude.
# See https://github.com/kisielk/errcheck#excluding-functions for details.
exclude-functions:
- encoding/json.Marshal
- encoding/json.MarshalIndent
# - io/ioutil.ReadFile
# - io.Copy(*bytes.Buffer)
# - io.Copy(os.Stdout)
# Checks types passed to the json encoding functions. Reports unsupported types and optionally reports occasions, where the check for the returned error can be omitted.
errchkjson:
# With check-error-free-encoding set to true, errchkjson does warn about errors
# from json encoding functions that are safe to be ignored,
# because they are not possible to happen.
#
# if check-error-free-encoding is set to true and errcheck linter is enabled,
# it is recommended to add the following exceptions to prevent from false positives:
#
# linters-settings:
# errcheck:
# exclude-functions:
# - encoding/json.Marshal
# - encoding/json.MarshalIndent
#
# Default: false
check-error-free-encoding: true
# Issue on struct encoding that doesn't have exported fields.
# Default: false
report-no-exported: false
# The 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:
# Check whether fmt.Errorf uses the %w verb for formatting errors.
# See the https://github.com/polyfloyd/go-errorlint for caveats.
# Default: true
errorf: true
# Permit more than 1 %w verb, valid per Go 1.20 (Requires errorf:true)
# Default: true
errorf-multi: true
# Check for plain type assertions and type switches.
# Default: true
asserts: true
# Check for plain error comparisons.
# Default: true
comparison: true
# Check exhaustiveness of enum switch statements.
exhaustive:
# Program elements to check for exhaustiveness.
# Default: [ switch ]
check:
- switch
- map
# Check switch statements in generated files also.
# Default: false
# check-generated: true
# Enum members matching the supplied regex do not have to be listed in
# switch statements to satisfy exhaustiveness.
# Default: ""
# ignore-enum-members: "Example.+"
# Enum types matching the supplied regex do not have to be listed in
# switch statements to satisfy exhaustiveness.
# Default: ""
# ignore-enum-types: "Example.+"
# Presence of "default" case in switch statements satisfies exhaustiveness,
# even if all enum members are not listed.
# Default: false
default-signifies-exhaustive: true
funlen:
# Checks the number of lines in a function.
# If lower than 0, disable the check.
# Default: 60
lines: -1
# Checks the number of statements in a function.
# If lower than 0, disable the check.
# Default: 40
statements: 40
goconst:
# Minimal length of string constant.
# Default: 3
min-len: 3
# Minimum occurrences of constant string count to trigger issue.
# Default: 3
min-occurrences: 2
# Ignore test files.
# Default: false
ignore-tests: true
# Look for existing constants matching the values.
# Default: true
match-constant: true
# Search also for duplicated numbers.
# Default: false
numbers: true
# Minimum value, only works with goconst.numbers
# Default: 3
min: 3
# Maximum value, only works with goconst.numbers
# Default: 3
max: 3
# Ignore when constant is not used as function argument.
# Default: true
ignore-calls: false
# Gci controls Go package import order and makes it always deterministic.
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(gitlab.flora.ltfs.tools) # Custom section: groups all imports with the specified Prefix.
- blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled.
- dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled.
# Skip generated files.
# Default: true
skip-generated: true
# Enable custom order of sections.
# If `true`, make the section order the same as the order of `sections`.
# Default: false
custom-order: true
# Computes and checks the cyclomatic complexity of functions.
gocyclo:
# Minimal code complexity to report, 30 by default but recommend 10-20.
min-complexity: 20
gomnd:
# List of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description.
# Default: ["argument", "case", "condition", "operation", "return", "assign"]
checks:
- argument
- case
# - condition
- operation
- return
- assign
# List of numbers to exclude from analysis.
# The numbers should be written as string.
# Values always ignored: "1", "1.0", "0" and "0.0"
# Default: []
# ignored-numbers:
# - '0666'
# - '0755'
# - '42'
# List of file patterns to exclude from analysis.
# Values always ignored: `.+_test.go`
# Default: []
# ignored-files:
# - 'magic1_.+\.go$'
# List of function patterns to exclude from analysis.
# Following functions are always ignored: `time.Date`,
# `strconv.FormatInt`, `strconv.FormatUint`, `strconv.FormatFloat`,
# `strconv.ParseInt`, `strconv.ParseUint`, `strconv.ParseFloat`.
# Default: []
# ignored-functions:
# - '^math\.'
# - '^http\.StatusText$'
# Detects Go structs that would take less memory if their fields were sorted.
maligned:
# Print struct with more effective memory layout, false by default.
suggest-new: true
# auto-fix: true
# Reports deeply nested if statements.
nestif:
# Minimal complexity of if statements to report.
# Default: 5
min-complexity: 10
# Detects code cloning.
dupl:
# Tokens count to trigger issue, 150 by default.
threshold: 150
# Finds commonly misspelled English words in comments.
misspell:
# Correct spellings using locale preferences for UK.
locale: US
# Reports long lines.
lll:
# Max line length, lines longer will be reported, 120 by default.
line-length: 160
# Tab width in spaces, 1 by default.
tab-width: 8
wsl:
# See https://github.com/bombsimon/wsl/blob/master/doc/configuration.md for documentation of available settings.
# These are the defaults for `golangci-lint`.
# Do strict checking when assigning from append (x = append(x, y)). If
# this is set to true - the append call must append either a variable
# assigned, called or used on the line above.
strict-append: true
# Allows assignments to be cuddled with variables used in calls on
# line above and calls to be cuddled with assignments of variables
# used in call on line above.
allow-assign-and-call: true
# Allows assignments to be cuddled with anything.
allow-assign-and-anything: false
# Allows cuddling to assignments even if they span over multiple lines.
allow-multiline-assign: true
# If the number of lines in a case block is equal to or lager than this
# number, the case *must* end white a newline.
force-case-trailing-whitespace: 0
# Allow blocks to end with comments.
allow-trailing-comment: false
# Allow multiple comments in the beginning of a block separated with newline.
allow-separated-leading-comment: false
# Allow multiple var/declaration statements to be cuddled.
allow-cuddle-declarations: false
# A list of call idents that everything can be cuddled with.
# Defaults to calls looking like locks.
allow-cuddle-with-calls: ["Lock", "RLock"]
# AllowCuddleWithRHS is a list of right hand side variables that is allowed
# to be cuddled with anything. Defaults to assignments or calls looking
# like unlocks.
allow-cuddle-with-rhs: ["Unlock", "RUnlock"]
# Causes an error when an If statement that checks an error variable doesn't
# cuddle with the assignment of that variable.
force-err-cuddling: false
# When force-err-cuddling is enabled this is a list of names
# used for error variables to check for in the conditional.
error-variable-names: ["err"]
# Causes an error if a short declaration (:=) cuddles with anything other than
# another short declaration.
# This logic overrides force-err-cuddling among others.
force-short-decl-cuddling: false
# Linter exception and limit rules.
issues:
# Excluding configuration per-path, per-linter, per-text and per-source.
# Default is true.
exclude-use-default: true
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
max-issues-per-linter: 0
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
max-same-issues: 0