-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.golangci.yml
337 lines (282 loc) · 8.26 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
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
326
327
328
329
330
331
332
333
334
335
336
337
run:
timeout: 2m
go: '1.19'
issues-exit-code: 1
tests: true
skip-dirs-use-default: true
modules-download-mode: vendor
allow-parallel-runners: true
output:
format: tab
print-issued-lines: true
print-linter-name: true
# Print all issue on single line.
# We should set to false 'cause if one single line has issues from different
# linters we will see only one of them.
uniq-by-line: false
sort-results: true
linters-settings:
gomoddirectives:
# Allow local `replace` directives. Default is false.
replace-local: false
# Allow to not explain why the version has been retracted in the `retract` directives. Default is false.
retract-allow-no-explanation: false
# Forbid the use of the `exclude` directives. Default is false.
exclude-forbidden: false
errcheck:
# Report about not checking of errors in type assertions: `a := b.(MyStruct)`.
check-type-assertions: true
# Report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`.
check-blank: true
# List of functions to exclude from checking, where each entry is a single
# function to exclude.
# see https://github.com/kisielk/errcheck#excluding-functions for details.
# Works in golangci-lint >= v1.42.1
exclude-functions: []
errorlint:
# Report non-wrapping error creation using fmt.Errorf, for instance:
#
# ```
# if _, err := := strconv.Atoi(numStr); err != nil {
# return fmt.Errorf("failed to convert: %s", err) <-- Will trigger an error at this line.
# }
# ```
errorf: true
forbidigo:
forbid:
# https://golang.org/doc/go1.16#ioutil
# Can be safely replaced with `io.Discard` 'cause `ioutil.Discard` just an
# alias to `io.Discard` since 1.16.
- ioutil.Discard
# Can be safely replaced with `io.NopCloser` 'cause `ioutil.NopCloser` just
# call `io.NopCloser` since 1.16.
- ioutil.NopCloser
# Can be safely replaced with `io.ReadAll` 'cause `ioutil.ReadAll` just call
# `io.ReadAll` since 1.16.
- ioutil.ReadAll
# Should use `os.ReadDir` instead but it have a little bit different behavior.
# Returns a slice of `os.DirEntry` rather than a slice of `fs.FileInfo`.
- ioutil.ReadDir
# Can be safely replaced with `os.ReadFile` 'cause `ioutil.ReadFile` just
# call `os.ReadFile` since 1.16.
- ioutil.ReadFile
# Should use `os.MkdirTemp` instead but it had different code so it may have
# different behavior.
- ioutil.TempDir
# Should use `os.CreateTemp` instead but it had different code so maybe it
# may have different behavior.
- ioutil.TempFile
# Can be safely replaced with `os.WriteFile` 'cause `ioutil.WriteFile` just
# call `os.WriteFile` since 1.16.
- ioutil.WriteFile
goconst:
# Minimal length of string constant.
min-len: 3
# Minimal occurrences count to trigger.
min-occurrences: 3
gocyclo:
min-complexity: 10
gofmt:
simplify: false
goimports:
local-prefixes: github.com/jsightapi/jsight-schema-go-library
gosimple:
go: "1.19"
checks:
- "all"
govet:
# We have many false-positive match for `err`.
check-shadowing: false
enable:
- assign
- atomic
- bools
- buildtag
- cgocall
- copylocks
- errorsas
- fieldalignment
- httpresponse
- ifaceassert
- loopclosure
- lostcancel
- nilfunc
- printf
- shift
- stdmethods
- stringintconv
- structtag
- testinggoroutine
- tests
- unmarshal
- unreachable
- unsafeptr
- unusedresult
enable-all: false
disable-all: false
lll:
# Max line length, lines longer will be reported.
# '\t' is counted as 1 character by default, and can be changed with the
# `tab-width` option.
line-length: 120
# In our code, tab is 4 space long.
tab-width: 4
misspell:
locale: US
nakedret:
max-func-lines: 5
nestif:
min-complexity: 5
revive:
# https://github.com/mgechev/revive#available-rules
rules:
# Make sure `context.Context` is the first argument of a function.
- name: context-as-argument
# Warns on some defer gotchas.
# https://blog.learngoprogramming.com/5-gotchas-of-defer-in-go-golang-part-iii-36a1ab3d6ef1
- name: defer
# Forbids . imports.
- name: dot-imports
# Looks for packages that are imported two or more times.
- name: duplicated-imports
# Spots if-then-else statements that can be refactored to simplify code reading.
- name: early-return
# Make sure error return parameter is the last.
- name: error-return
# Warns on getters that do not yield any result.
- name: get-return
# Warns on if-then-else statements with identical then and else branches.
- name: identical-branches
# Warns on redundant `if` when returning an error.
- name: if-return
# Warns on `i += 1` and `i -= 1`.
- name: increment-decrement
# Warns on assignments to value-passed method receivers.
- name: modifies-value-receiver
# Warns on redundant variables when iterating over a collection.
- name: range
# Warns on function calls that will lead to (direct) infinite recursion.
- name: unconditional-recursion
# Warns when a public return is from unexported type.
- name: unexported-return
# Warns on unnecessary statements.
- name: unnecessary-stmt
# Warns on unused method receivers.
- name: unused-receiver
staticcheck:
enable: true
nolintlint:
# Require machine-readable nolint directives (i.e. with no leading space)
allow-leading-space: false
# Report any unused nolint directives.
allow-unused: false
# Require an explanation for nolint directives.
require-explanation: true
# Exclude following linters from requiring an explanation.
allow-no-explanation:
- lll
# Require nolint directives to be specific about which linter is being skipped.
require-specific: true
unused:
check-exported: true
linters:
disable-all: true
enable:
- bodyclose
- depguard
- dogsled
- dupl
- errcheck
- exportloopref
# - funlen
- gochecknoinits
- goconst
- gocritic
- gocyclo
- gofmt
- goimports
# - gomnd
- goprintffuncname
- gosec
- gosimple
- govet
- ineffassign
- lll
- misspell
- nakedret
- noctx
- nolintlint
- staticcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- whitespace
# don't enable:
# - asciicheck
# - scopelint
# - gochecknoglobals
# - gocognit
# - godot
# - godox
# - goerr113
# - interfacer
# - maligned
# - nestif
# - prealloc
# - testpackage
# - revive
# - wsl
issues:
# Maximum count of issues with the same text. Set to 0 to disable.
max-same-issues: 0
include:
# ```
# switch ... {
# case ...:
# break <-- Will trigger an error at this line.
# }
# ```
- "ineffective break statement. Did you mean to break out of the outer loop"
exclude-rules:
- path: _test\.go
linters:
- dupl
- errcheck
- goconst
- gocritic
- gocyclo
- gosec
- ifshort
- lll
- unparam
# Ignore long lines in comments.
- source: "^[ \t]*// "
linters:
- lll
# Ignore lll in lines with `nolint` (but without `lll` in ignored)
- source: "//nolint:[[:graph:]]*[^l]{3}[[:graph:]]*"
linters:
- lll
# Ignore to-do comments.
- source: "//[ \t]*todo"
linters:
- lll
# We already have bunch of code with that name convention, so it's okay for now
# to skip this check.
- source: "(Json|Uuid|Uri|jApi)"
linters:
- stylecheck
# Skip for now, should refactor in the future
- text: "string `(: true|: false|null)` has \\d+ occurrences, make it a constant"
linters:
- goconst
- text: "fieldalignment: struct"
path: (_test\.go|internal/cmd|test/)
- text: "ST1005: error strings should not be capitalized"
linters:
- stylecheck
severity:
default-severity: error
case-sensitive: false