-
Notifications
You must be signed in to change notification settings - Fork 14
/
.golangci.yml
282 lines (255 loc) · 7.08 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
# refrence: https://github.com/golangci/golangci-lint/blob/master/.golangci.reference.yml
# doc: https://golangci-lint.run/usage/quick-start/
# ex:
# * https://gist.github.com/brpaz/dc3635f52ccfed2eb5772c4cb484cab6
# * https://gist.github.com/maratori/47a4d00457a92aa426dbd48a18776322
run:
# Timeout for analysis, e.g. 30s, 5m.
# Default: 1m
timeout: 3m
linters:
fast: false
enable:
- asciicheck
- bidichk
- bodyclose
- containedctx
- contextcheck
- decorder
- depguard
- dogsled
- dupl
- durationcheck
- errchkjson
- errname
- errorlint
- exhaustive
- exportloopref
- forcetypeassert
- goconst
- gocritic
- gofmt
- goheader
- goimports
- goprintffuncname
- gosec
- importas
- interfacebloat
- makezero
- misspell
- nakedret
- nilerr
- nilnil
- noctx
- nolintlint
- nonamedreturns
- prealloc
- predeclared
- reassign
- revive
- stylecheck
- tenv
- testpackage
- tparallel
- unconvert
- unparam
- usestdlibvars
- whitespace
- testableexamples
- staticcheck
## code complexity
- funlen
- cyclop
- gocognit
- gocyclo
- maintidx
- nestif
#- godox # prints all TODOs (and more) leave disabled
#- goerr113 # WIP
- wrapcheck
## disabled for generics
# https://github.com/golangci/golangci-lint/issues/2649
#- rowserrcheck
#- sqlclosecheck
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
exhaustive:
# Program elements to check for exhaustiveness.
# Default: [ switch ]
check:
- switch
- map
gocritic:
# Settings passed to gocritic.
# The settings key is the name of a supported gocritic checker.
# The list of supported checkers can be find in https://go-critic.github.io/overview.
settings:
captLocal:
# Whether to restrict checker to params only.
# Default: true
paramsOnly: false
underef:
# Whether to skip (*x).method() calls where x is a pointer receiver.
# Default: true
skipRecvDeref: false
govet:
# Enable all analyzers.
# Default: false
enable-all: true
# Disable analyzers by name.
# Run `go tool vet help` to see all analyzers.
# Default: []
disable:
- fieldalignment # way too strict
# Settings per analyzer.
settings:
shadow:
# Whether to be strict about shadowing; can be noisy.
# Default: false
strict: true
funlen:
# Checks the number of lines in a function.
# If lower than 0, disable the check.
# Default: 60
lines: 150
# Checks the number of statements in a function.
# If lower than 0, disable the check.
# Default: 40
statements: 100
cyclop:
# The maximal code complexity to report.
# Default: 10
max-complexity: 30
# The maximal average package complexity.
# If it's higher than 0.0 (float) the check is enabled
# Default: 0.0
package-average: 10
godox:
# report any comments starting with keywords, this is useful for TODO or FIXME comments that
# might be left in the code accidentally and should be resolved before merging
keywords: # default keywords are TODO, BUG, and FIXME, these can be overwritten by this setting
- TODO
- BUG
- FIXME
- NOTE
- OPTIMIZE # marks code that should be optimized before merging
- HACK # marks hack-arounds that should be removed before merging
nestif:
# default 4
min-complexity: 7
staticcheck:
# SAxxxx checks in https://staticcheck.io/docs/configuration/options/#checks
# Default: ["*"]
checks: [ "all" ]
wrapcheck:
ignorePackageGlobs:
- zonetools/util/errors
- encoding/*
revive:
# https://github.com/mgechev/revive
# Maximum number of open files at the same time.
# See https://github.com/mgechev/revive#command-line-flags
# Defaults to unlimited.
#max-open-files: 2048
# When set to false, ignores files with "GENERATED" header, similar to golint.
# See https://github.com/mgechev/revive#available-rules for details.
# Default: false
ignore-generated-header: true
# Sets the default severity.
# See https://github.com/mgechev/revive#configuration
# Default: warning
#severity: error
# Enable all available rules.
# Default: false
# enable-all-rules: true
# some rules require a config
# provide minimcal base config here to allow revive to work
rules:
- name: context-keys-type
- name: time-equal
- name: time-naming
- name: var-declaration
- name: unexported-return
- name: errorf
- name: blank-imports
- name: context-as-argument
- name: dot-imports
- name: error-return
- name: error-strings
- name: error-naming
- name: exported
- name: if-return
- name: increment-decrement
- name: package-comments
- name: range
- name: receiver-naming
- name: indent-error-flow
- name: empty-block
- name: superfluous-else
- name: confusing-naming
- name: get-return
- name: modifies-parameter
- name: confusing-results
- name: deep-exit
- name: unused-parameter
- name: unreachable-code
- name: flag-parameter
- name: unnecessary-stmt
- name: struct-tag
- name: modifies-value-receiver
- name: constant-logical-expr
- name: bool-literal-in-expr
- name: redefines-builtin-id
- name: range-val-in-closure
- name: range-val-address
- name: waitgroup-by-value
- name: atomic
- name: call-to-gc
- name: duplicated-imports
- name: import-shadowing
- name: bare-return
- name: unused-receiver
- name: string-of-int
- name: early-return
- name: unconditional-recursion
- name: identical-branches
- name: unexported-naming
- name: nested-structs
- name: useless-break
- name: optimize-operands-order
- name: use-any
- name: datarace
# - name: max-public-structs
# disabled: true
# - name: argument-limit
# disabled: true
# - name: function-result-limit
# disabled: true
# - name: cyclomatic
# disabled: true
# - name: file-header
# disabled: true
# - name: banned-characters
# disalbed: true
# - name: function-length
# disabled: true
# - name: cognitive-complexity
# disabled: true
# - name: line-length-limit
# disabled: true
# 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
issues:
# Maximum count of issues with the same text.
# Set to 0 to disable.
# Default: 3
max-same-issues: 50
exclude-rules:
- path: "importer/undo/undo_import.go"
linters: [ dupl ]