-
Notifications
You must be signed in to change notification settings - Fork 23
/
.golangci.yml
295 lines (241 loc) · 8.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
283
284
285
286
287
288
289
290
291
292
293
294
295
linters-settings:
# Checks for unchecked errors
errcheck:
# Report about not checking of errors in type assertions: `a := b.(MyStruct)`. # Default: false
check-type-assertions: true
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`. # Default: false
check-blank: true # Default: false
# Provides diagnostics that check for bugs, performance and style issues
gocritic:
# Enable multiple checks by tags in addition to default checks.
# See https://github.com/go-critic/go-critic#usage -> section "Tags".
# Default: []
enabled-tags:
- diagnostic
- performance
- style
disabled-tags:
- experimental
- opinionated
# 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
paramsOnly: false # Default: true
underef:
# Whether to skip (*x).method() calls where x is a pointer receiver
skipRecvDeref: false # Default: true
rangeExprCopy:
sizeThreshold: 512 # Default: 512
skipTestFuncs: true
rangeValCopy:
sizeThreshold: 200 # Default: 128
skipTestFuncs: true
hugeParam:
sizeThreshold: 100 # Default: 80
# Examines Go source code and reports suspicious constructs. It is roughly the same as 'go vet' and uses its passes.
govet:
enable:
# Check for shadowed variables
- shadow
settings:
shadow:
# Whether to be strict about shadowing; can be noisy.
strict: false # Default: true
# Checks that functions with naked returns are not longer than a maximum size (can be zero).
nakedret:
max-func-lines: 30 # Default: 30
# analyzer that detects using os.Setenv instead of t.Setenv since Go1.17.
tenv:
# The option `all` will run against whole test files (`_test.go`) regardless of method/function signatures.
# Otherwise, only methods that take `*testing.T`, `*testing.B`, and `testing.TB` as arguments are checked.
# Default: false
all: false
# Reports ill-formed or insufficient nolint directives
nolintlint:
# Disable to ensure that all nolint directives actually have an effect.
# Default: false
allow-unused: true
# Exclude following linters from requiring an explanation.
# Default: []
allow-no-explanation: []
# Enable to require an explanation of nonzero length after each nolint directive.
# Default: false
require-explanation: true
# Enable to require nolint directives to mention the specific linter being suppressed.
# Default: false
require-specific: true
revive:
enable-all-rules: true
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md
rules:
- name: add-constant
disabled: true
- name: argument-limit
arguments: [10]
- name: cognitive-complexity
disabled: true
- name: confusing-results
disabled: true
- name: cyclomatic
disabled: true
- name: deep-exit
disabled: true
- name: empty-lines
disabled: true
- name: exported
arguments: ["disableStutteringCheck"]
- name: flag-parameter
disabled: true
- name: function-length
disabled: true
- name: function-result-limit
arguments: [8]
- name: get-return
disabled: true
- name: if-return
disabled: true
- name: line-length-limit
arguments: [250]
- name: max-control-nesting
arguments: [7]
- name: max-public-structs
arguments: [8]
- name: var-naming
arguments:
- [] # allowlist
- [] # blocklist
- [{ "upperCaseConst": true, "skipPackageNameChecks": true }]
- name: unexported-return
disabled: true
- name: unhandled-error
arguments:
[
"fmt.Printf",
"fmt.Fprintf",
"fmt.Println",
"io.Closer.Close",
"os.File.Close",
]
- name: unused-receiver
disabled: true
goconst:
# Minimum occurrences of constant string count to trigger issue.
# Default: 3
min-occurrences: 5
# Ignore test files.
# Default: false
ignore-tests: true
stylecheck:
checks: ["all", "-ST1003"]
linters:
# Set to true runs only fast linters
fast: false
enable:
# Check for pass []any as any in variadic func(...any)
- asasalint
# Checks for unusual ASCII identifiers.
- asciicheck
# Checks for dangerous unicode character sequences.
- bidichk
# Checks whether HTTP response body is closed successfully.
- bodyclose
# Check for two durations multiplied together.
- durationcheck
# Forces to not skip error check.
- errcheck
# Checks `Err-` prefix for var and `-Error` suffix for error type.
- errname
# Suggests to use `%w` for error-wrapping.
- errorlint
# Checks for pointers to enclosing loop variables.
- exportloopref
# Validates go compiler directive comments (//go:)
- gocheckcompilerdirectives
# Finds repeated strings that could be replaced by a constant
- goconst
# Maintains checks which are currently not implemented in other linters.
- gocritic
# Checks standard formatting (whitespace, indentation, etc.)
- gofmt
# Checks
- goimports
# Allow or ban replace directives in go.mod or force explanation for retract directives.
- gomoddirectives
# Powerful security-oriented linter. But requires some time to
# configure it properly, see https://github.com/securego/gosec#available-rules
- gosec
# Linter that specializes in simplifying code.
- gosimple
# Examines Go source code and reports suspicious constructs. It is roughly the same as 'go vet' and uses its passes.
- govet
# Detects when assignments to existing variables are not used
- ineffassign
# Spell checker
- misspell
# Checks that functions with naked returns are not longer than a maximum size (can be zero).
- nakedret
# Both require a bit more explicit returns.
- nilerr
# Finds sending HTTP request without context.Context.
- noctx
# Forces comment why another check is disabled.
- nolintlint
# Finds shadowing of Go's predeclared identifiers
- predeclared
# Lint your Prometheus metrics name
- promlinter
# Drop-in replacement of `golint`.
- revive
# For `database/sql` package.
- rowserrcheck
- sqlclosecheck
# Detects bugs, suggests code simplifications, points out dead code, etc
- staticcheck
# Replacement for `golint`, similar to `revive`.
- stylecheck
# Test-related checks
- tenv
- testableexamples
- testifylint
- thelper
- tparallel
# Parses and type-checks
- typecheck
# Remove unnecessary type conversions
- unconvert
# Finds unused parameters
# - unparam
# Finds unused declarations
- unused
# Detect the possibility to use variables/constants from stdlib.
- usestdlibvars
# Finds wasted assignment statements.
- wastedassign
# detects the wrong usage of zerolog that a user forgets to dispatch zerolog.Event
- zerologlint
issues:
# exclude:
# - "var-naming: don't use an underscore in package name"
exclude-rules:
# ignore shadowing of err and ctx
- linters: [govet]
text: 'shadow: declaration of "(err|ctx)" shadows declaration at'
# tolerate long functions in tests
- linters: [revive]
path: "(.+)_test.go"
text: "function-length: .*"
# tolerate long lines in tests
- linters: [revive]
path: "(.+)_test.go"
text: "line-length-limit: .*"
# tolerate deep-exit in tests
- linters: [revive]
path: "(.+)_test.go"
text: "deep-exit: .*"
# tolerate import shadowing in tests
- linters: [revive]
path: "(.+)_test.go"
text: "import-shadowing: The name ('require') shadows an import name"