-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy path.golangci.yaml
325 lines (280 loc) · 8.34 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
# This file contains all available configuration options
# with their default values.
# options for analysis running
run:
# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 5m
# exit code when at least one issue was found, default is 1
issues-exit-code: 1
# include test files or not, default is true
tests: true
modules-download-mode: readonly
# Allow multiple parallel golangci-lint instances running.
# If false (default) - golangci-lint acquires file lock on start.
allow-parallel-runners: true
go: "1.23"
# output configuration options
output:
# colored-line-number|line-number|json|tab|checkstyle|code-climate|junit-xml|github-actions
# 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
# make issues output unique by line, default is true
uniq-by-line: true
# add a prefix to the output file references; default is no prefix
path-prefix: ""
# sorts results by: filepath, line and column
sort-results: true
# all available settings of specific linters
linters-settings:
revive:
rules:
- name: unused-parameter
disabled: true
errcheck:
# report about not checking of errors in type assertions: `a := b.(MyStruct)`;
# default is false: such cases aren't reported by default.
check-type-assertions: false
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
# default is false: such cases aren't reported by default.
check-blank: false
exclude-functions:
- (*github.com/valyala/bytebufferpool.ByteBuffer).Write
- (*github.com/valyala/bytebufferpool.ByteBuffer).WriteByte
- (*github.com/valyala/bytebufferpool.ByteBuffer).WriteString
errorlint:
# Check whether fmt.Errorf uses the %w verb for formatting errors. See the readme for caveats
errorf: true
# Check for plain type assertions and type switches
asserts: true
# Check for plain error comparisons
comparison: true
forbidigo:
# Forbid the following identifiers (identifiers are written using regexp):
forbid:
- ^print.*$
- ^fmt\.Println$
- ^fmt\.Print$
gofmt:
simplify: true
rewrite-rules:
- pattern: "interface{}"
replacement: "any"
funlen:
lines: 60
statements: 40
gocyclo:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 15
godot:
# comments to be checked: `declarations`, `toplevel`, or `all`
scope: declarations
# list of regexps for excluding particular comment lines from check
exclude: []
# example: exclude comments which contain numbers
# - '[0-9]+'
# check that each sentence starts with a capital letter
capital: false
gci:
sections:
- standard # Captures all standard packages if they do not match another section.
- default # Contains all imports that could not be matched to another section type.
- prefix(github.com/bangumi/server) # Groups all imports with the specified Prefix.
depguard:
rules:
main:
files:
- "$all"
- "!$test"
- "!**/internal/pkg/test/**.go"
deny:
- pkg: "github.com/sirupsen/logrus"
desc: 'use "app/pkg/logger"'
- pkg: "github.com/golang/mock"
desc: 'use "github.com/stretchr/testify/mock" and "github.com/vektra/mockery"'
- pkg: "github.com/stretchr/testify"
desc: "test assert package not allowed"
test:
files:
- "$test"
- "**/internal/pkg/test/**.go"
deny:
- pkg: "github.com/golang/mock"
desc: 'use "github.com/stretchr/testify/mock" and "github.com/vektra/mockery"'
mnd:
# settings:
# mnd:
# the list of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description.
checks:
- argument
- case
- operation
- return
- assign
ignored-functions: [strconv\..*, time\..*, make, math\..*, strings\..*]
ignored-numbers: ["1", "2", "3", "10", "100", "1000", "10000"]
gosimple:
# Select the Go version to target. The default is '1.13'.
# https://staticcheck.io/docs/options#checks
checks: ["all"]
importas:
no-unaliased: false
no-extra-aliases: false
alias:
- pkg: "log"
alias: stdLog
- pkg: "gorm.io/gorm/logger"
alias: gormLogger
- pkg: "github.com/go-playground/universal-translator"
alias: ut
- pkg: "github.com/go-playground/validator/v10/translations/zh"
alias: zhTranslations
lll:
# max line length, lines longer will be reported. Default is 120.
# '\t' is counted as 1 character by default, and can be changed with the tab-width option
line-length: 120
# tab width in spaces. Default to 1.
tab-width: 2
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
staticcheck:
# Select the Go version to target. The default is '1.13'.
# https://staticcheck.io/docs/options#checks
checks: ["all"]
stylecheck:
# Select the Go version to target. The default is '1.13'.
testpackage:
# regexp pattern to skip files
skip-regexp: (export|internal)_test\.go
exhaustive:
# check switch statements in generated files also
check-generated: false
# indicates that switch statements are to be considered exhaustive if a
# 'default' case is present, even if all enum members aren't listed in the
# switch
default-signifies-exhaustive: true
govet:
enable-all: true
disable:
- fieldalignment
# - shadow
nlreturn:
block-size: 3
gosec:
excludes:
- G115
tagliatelle:
# Check the struck tag name case.
case:
# Use the struct field name to check the name of the struct tag.
# Default: false
use-field-name: false
rules:
# Any struct tag type can be used.
# Support string case: `camel`, `pascal`, `kebab`, `snake`, `goCamel`, `goPascal`, `goKebab`, `goSnake`, `upper`, `lower`
json: snake
yaml: snake
linters:
disable-all: true
enable:
- asasalint
- asciicheck
- bidichk
- containedctx
- depguard
- dogsled
- durationcheck
- errcheck
- errchkjson
- errname
- errorlint
# https://github.com/golangci/golangci-lint/issues/5065
- exhaustive
- copyloopvar
- forbidigo
- forcetypeassert
- funlen
- gci
- gocheckcompilerdirectives
- gochecknoglobals
- gochecknoinits
- gocognit
- goconst
- gocritic
- gocyclo
- godot
- gofmt
- mnd
- gomoddirectives
- gomodguard
- goprintffuncname
- gosec
- gosimple
- govet
- grouper
- importas
- ineffassign
- interfacebloat
- lll
- loggercheck
- maintidx
- makezero
- misspell
# - musttag
- nakedret
- nestif
- nilnil
- noctx
# - nosprintfhostport
- paralleltest
- predeclared
- promlinter
- reassign
# - staticcheck
- stylecheck
- tagliatelle
- tenv
- testableexamples
- testpackage
- thelper
- tparallel
- typecheck
- unconvert
- unparam
- unused
- usestdlibvars
- whitespace
- revive
fast: false
issues:
new: false
fix: false
exclude-use-default: true
exclude-rules:
- path: "cmd/.*"
linters: [gochecknoglobals, gochecknoinits, wrapcheck]
- path: '.*_test\.go'
linters: [gocritic, gochecknoglobals, godot, nosnakecase, funlen]
- source: "var .* = pool.New"
linters: [gochecknoglobals]
- source: 'var Module = fx\.Module\('
linters: [gochecknoglobals]
- source: 'var .* = reflect\.TypeOf'
linters: [gochecknoglobals]
- source: 'var .* sync\.Once'
linters: [gochecknoglobals]
- linters: [err113, errorlint]
source: "if err == redis.Nil {"
# https://github.com/kunwardeep/paralleltest/issues/8
- linters:
- paralleltest
text: "Range statement for test \\S+ does not use range value in test Run"
- linters:
- nilerr
source: "return false, nil"