This repository has been archived by the owner on Jul 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
.golangci.yml
280 lines (255 loc) · 8.46 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
# Config file for golangci-lint
# options for analysis running
run:
# timeout for analysis, e.g. 30s, 5m, default is 1m. This has to be long
# enough to handle an empty cache on a slow machine.
timeout: 2m
# include test files or not, default is true
tests: true
# Run "golangci-lint linters" for a list of available linters. Don't enable
# any linters here, or they can't be disabled on the commandline.
linters:
disable-all: true
enable:
- asciicheck
- bodyclose
- deadcode
- depguard
- errcheck
- errorlint
- exhaustive
- exportloopref
- gocritic
# - goerr113
- gofumpt
- goimports
- goprintffuncname
- gosec
- gosimple
- govet
- ineffassign
- makezero
- misspell
- nakedret
# - noctx
- nolintlint
- prealloc
- predeclared
- revive
- rowserrcheck
- sqlclosecheck
- staticcheck
- structcheck
- tparallel
- typecheck
- unconvert
- varcheck
- wastedassign
fast: false
# all available settings of specific linters
linters-settings:
errcheck:
# 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
# [deprecated] comma-separated list of pairs of the form pkg:regex
# the regex is used to ignore names within pkg. (default "fmt:.*").
ignore: fmt:.*,bufio:Write(String)?,database/sql:Close,io:Close,net:Close,os:(Close|Remove(All)?|Setenv),github.com/go-kit/kit/log:Log
exhaustive:
# If enum-like constants don't use all cases in a switch statement,
# consider a default good enough.
default-signifies-exhaustive: true
gocritic:
# all checks list: https://github.com/go-critic/checkers
# Enable all checks by enabling all tags, then disable a few.
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
disabled-checks:
# Don't be aggressive with comments.
- commentedOutCode
# Catches legit uses of case checking.
- equalFold
# Many defers can be skipped when exiting. Could fix this with a log.Fatal replacement.
- exitAfterDefer
# Disagree with the style recommendations for these three.
- ifElseChain
- octalLiteral
- unnamedResult
- filepathJoin
- tooManyResultsChecker
settings:
captLocal:
paramsOnly: false
hugeParam:
# Allowing 512 byte parameters.
sizeThreshold: 512
nestingReduce:
# How many nested blocks before suggesting early exit.
bodyWidth: 4
rangeExprCopy:
# Avoid copying arrays larger than this in range statement.
sizeThreshold: 512
rangeValCopy:
# Avoid copying range values larger than this on every iteration.
sizeThreshold: 128
truncateCmp:
skipArchDependent: false
underef:
skipRecvDeref: false
goimports:
# put imports beginning with prefix after 3rd-party packages;
# it's a comma-separated list of prefixes
local-prefixes: github.com/die-net/
govet:
# Enable most of the non-default linters too.
enable:
- asmdecl
- assign
- atomic
- atomicalign
- bools
- buildtag
- cgocall
- composite
- copylock
- durationcheck
- errorsas
- findcall
- httpresponse
- ifaceassert
- loopclosure
- lostcancel
- nilfunc
- nilness
- printf
- shadow
- shift
- sortslice
- stdmethods
- stringintconv
- structtag
- testinggoroutine
- tests
- unmarshal
- unreachable
- unsafeptr
- unusedresult
disable:
# We need to fix a few tests that rely on this first.
- deepequalerrors
nakedret:
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
max-func-lines: 6
nolintlint:
allow-unused: false
allow-leading-space: false
require-explanation: true
revive:
# Show all issues, not just those with a high confidence
confidence: 0.0
rules:
- name: atomic
# - name: bare-return
- name: blank-imports
# - name: confusing-naming
# - name: confusing-results
- name: constant-logical-expr
- name: context-as-argument
- name: context-keys-type
# - name: deep-exit
# - name: defer
- name: dot-imports
# - name: early-return
# - name: empty-block
- name: error-naming
- name: error-return
- name: error-strings
- name: errorf
- name: exported
# - name: get-return
- name: identical-branches
- name: if-return
- name: increment-decrement
- name: indent-error-flow
# - name: import-shadowing
- name: modifies-parameter
# - name: modifies-value-receiver
- name: package-comments
- name: range
- name: range-val-in-closure
- name: range-val-address
- name: receiver-naming
# - name: redefines-builtin-id
- name: string-of-int
# - name: struct-tag
- name: superfluous-else
- name: time-naming
# - name: var-naming
# - name: var-declaration
- name: unconditional-recursion
# - name: unexported-naming
- name: unexported-return
- name: unnecessary-stmt
- name: unreachable-code
# - name: unused-parameter
# - name: unused-receiver
- name: waitgroup-by-value
# output configuration options
output:
# colored-line-number|line-number|json|tab|checkstyle, default is "colored-line-number"
format: line-number
# print lines of code with issue, default is true
print-issued-lines: false
# sorts results by: filepath, line and column
sort-results: true
issues:
# List of regexps of issue texts to exclude, empty list by default.
# But independently from this option we use default exclude patterns,
# it can be disabled by `exclude-use-default: false`. To list all
# excluded by default patterns execute `golangci-lint run --help`
exclude:
# revive: We don't require comments, only that they be properly formatted
- should have( a package)? comment
# revive: Don't force variable scope changes
- (indent-error-flow|superfluous-else).*drop this else and outdent its block .move short variable declaration to its own line if necessary.
# govet: Allow the most common form of shadowing
- declaration of .err. shadows declaration
# gocritic: We use named Err return as part of our defer handling pattern.
- captLocal. .Err. should not be capitalized
# govet: Allow an unused noCopy struct field to disallow copying
- .noCopy. is unused
# gosec: Let errcheck complain about this instead
- G104. Errors unhandled
# gosec: All URLs are variable in our code; this isn't useful
- G107. Potential HTTP request made with variable url
# gosec: Complaining about every exec.Command() is annoying; we'll audit them
- G204. Subprocess launching should be audited
- G204. Subprocess launched with variable
- G204. Subprocess launched with function call as argument or cmd arguments
# gosec: Too many false positives for legit uses of files and directories
- G301. Expect directory permissions to be 0750 or less
- G302. Expect file permissions to be 0600 or less
- G306. Expect WriteFile permissions to be 0600 or less
# gosec: False positive is triggered by 'src, err := ioutil.ReadFile(filename)'
- G304. Potential file inclusion via variable
# gosec: Complaining about every use of math/rand is annoying.
- G404. Use of weak random number generator .math/rand instead of crypto/rand.
# gosec: We're allowing SHA1 for now, but MD5, DES, and RC4 need to be audited
- G401. Use of weak cryptographic primitive
- G505. Blocklisted import crypto/sha1. weak cryptographic primitive
# Exclude some linters from running on template-generated code, where we
# can't fix the output.
exclude-rules:
# 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