-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path.golangci.yml
244 lines (237 loc) · 5.55 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
# 运行配置
run:
# 要使用的CPU核心数
# concurrency: 4
# 分析超时,30m, 5m, 默认1m
timeout: 1m
# 退出代码, default is 1
issues-exit-code: 1
# 是否包含单元测试文件, default is true
tests: true
# 跳过默认目录:vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
skip-dirs-use-default: true
# 包管理模式,go modules使用readonly
modules-download-mode: readonly
# 输出配置
output:
# 输出格式:colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
formats: colored-line-number
# 打印有问题的代码行号, default is true
print-issued-lines: true
# 在问题文本的未尾打印检查器名称, default is true
print-linter-name: true
# 使问题的输出逐行唯一, default is true
uniq-by-line: true
# 质量检查配置
linters-settings:
# 错误检查
errcheck:
# 检查类型错误
check-type-assertions: false
# 检查空标识符
check-blank: true
# 忽略文件
exclude-functions: fmt:.*,io/ioutil:^Read.*
govet:
enable-all: true
# 检查函数的复杂程度
gocyclo:
# 最小复杂性
min-complexity: 30
lll:
line-length: 120
tab-width: 1
unparam:
check-exported: false
gocritic:
enabled-tags:
- performance
settings: # settings passed to gocritic
captLocal: # must be valid enabled check name
paramsOnly: true
rangeValCopy:
sizeThreshold: 32
linters:
enable-all: true
# enable:
# - bodyclose
# - depguard
# - dogsled
# - dupl
# - errcheck
# - exportloopref
# - exhaustive
# - gochecknoinits
# - goconst
# - gocritic
# - gofmt
# - govet
# - goimports
# - goprintffuncname
# - gosec
# - gosimple
# - ineffassign
# - lll
# - misspell
# - noctx
# - rowserrcheck
# - staticcheck
# - stylecheck
# - typecheck
# - unconvert
# - unparam
# - unused
# - whitespace
disable:
- gci
- exportloopref
- intrange
- copyloopvar
- err113
- paralleltest
- nlreturn
- gofumpt
- wsl
- godot
- dupl
- mnd
- nonamedreturns
- testpackage
- cyclop
- funlen
- gochecknoglobals
- tagliatelle
- nakedret
- exhaustruct
- tagalign
disable-all: false
# presets:
# - bugs
# 只运行所有启用的 linter 中支持快速检查的 linter
fast: false
issues:
# exclude:
# - /bin
# - /output
# - /.idea
exclude-dirs:
- vendor
- .idea
- bin
- output
exclude-rules:
# 设置某个目录的排除规则
- path: _test\.go
linters:
- depguard
- path: internal/hmac/
text: "weak cryptographic primitive"
linters:
- gosec
- linters:
- revive
text: "package-comments:"
- linters:
- gomoddirectives
text: "local replacement are not allowed"
- linters:
- stylecheck
text: "ST1016:"
- linters:
- maintidx
text: "Cyclomatic Complexity:"
- linters:
- canonicalheader
text: "X-Real-IP"
- linters:
- unused
text: "tableName"
- linters:
- revive
text: "exported:"
- linters:
- govet
text: "fieldalignment"
- linters:
- gosec
text: "G115"
- linters:
- varnamelen
text: "too short"
- linters:
- gosmopolitan
text: "string literal contains rune in Han script"
- linters:
- nestif
text: "has complex nested blocks"
- linters:
- gocritic
text: "hugeParam:"
- linters:
- wastedassign
text: "assigned to err, but reassigned without using the value"
- linters:
- staticcheck
text: "SA6002:"
- linters:
- staticcheck
text: "SA9003:"
- linters:
- gosec
text: "G103:"
# 排除stylecheck的导出未注释的消息
- linters:
- stylecheck
text: "ST1020:"
# 排除stylecheck的导出未注释的消息
- linters:
- stylecheck
text: "ST1006:"
- linters:
- depguard
text: "is not allowed from list 'Main'"
- linters:
- gci
text: "File is not `gci`-ed with --skip-generated -s standard -s default"
- linters:
- wrapcheck
text: "error returned from external package is unwrapped"
- linters:
- stylecheck
text: "ST1000:"
# 排除stylecheck的导出未注释的消息
- linters:
- stylecheck
text: "ST1021:"
# 排除stylecheck的导出未注释的消息
- linters:
- stylecheck
text: "ST1022:"
- linters:
- revive
text: "receiver-naming:"
- linters:
- lll
text: "line is"
- linters:
- gocognit
text: "is high"
- linters:
- gocritic
text: "unnecessaryDefer:"
- linters:
- gocyclo
text: "is high"
# Exclude lll issues for long lines with go:generate
# - linters:
# - lll
# source: "^//go:generate "
# Independently from option `exclude` we use default exclude patterns,
# it can be disabled by this option. To list all
# excluded by default patterns execute `golangci-lint run --help`.
# Default value for this option is true.
exclude-use-default: false
# 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