-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.golangci.yml
More file actions
388 lines (385 loc) · 15.6 KB
/
.golangci.yml
File metadata and controls
388 lines (385 loc) · 15.6 KB
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
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
version: "2"
run:
issues-exit-code: 1
tests: true
linters:
enable:
- bodyclose
- dupl
- funlen
- ginkgolinter
- gochecknoinits
- goconst
- gocritic
- gocyclo
- goprintffuncname
- gosec
- lll
- misspell
- mnd
- nakedret
- revive
- staticcheck
- unconvert
- unparam
- whitespace
disable:
- depguard
settings:
depguard:
rules:
main:
deny:
- pkg: github.com/pkg/errors
desc: use standard errors package
dupl:
threshold: 100
funlen:
lines: 100
statements: 50
ginkgolinter:
forbid-focus-container: true
forbid-spec-pollution: true
force-expect-to: true
force-succeed: true
validate-async-intervals: true
suppress-len-assertion: false
suppress-nil-assertion: false
suppress-err-assertion: false
suppress-compare-assertion: false
suppress-async-assertion: false
suppress-type-compare-assertion: false
gocognit:
min-complexity: 20
goconst:
min-len: 3
min-occurrences: 3
gocritic:
disabled-checks:
- wrapperFunc
enabled-tags:
- performance
- style
- experimental
gocyclo:
min-complexity: 15
govet:
enable:
- shadow
lll:
line-length: 120
misspell:
locale: US
revive:
severity: warning
confidence: 0.8
rules:
- name: blank-imports
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
- name: error-return
- name: error-strings
- name: error-naming
- name: exported
- name: increment-decrement
- name: var-naming
- name: var-declaration
- name: package-comments
- name: range
- name: receiver-naming
- name: time-naming
- name: unexported-return
- name: indent-error-flow
- name: errorf
- name: empty-block
- name: superfluous-else
- name: unused-parameter
- name: unreachable-code
- name: redefines-builtin-id
staticcheck:
# Enable all checks by default, then selectively disable problematic ones
checks:
- "all"
# Disable overly opinionated style checks that don't add much value
- "-ST1000" # Package comment should be of the form "Package x ..."
- "-ST1003" # Should not use ALL_CAPS in Go names; use CamelCase (too pedantic)
- "-ST1016" # Use consistent method receiver names (enabled by default but can be noisy)
- "-ST1020" # Comment should be of the form "Foo returns ..." (too pedantic)
- "-ST1021" # Comment should be of the form "Foo returns ..." (too pedantic)
- "-ST1022" # Comment should be of the form "Foo returns ..." (too pedantic)
- "-ST1023" # Redundant type in variable declaration (can be useful for clarity)
# Disable SA9003 (empty body in if/for/range/switch) - sometimes needed for TODO items
- "-SA9003" # Empty body in if/for/range/switch
# Enable important performance and correctness checks explicitly
- "SA1000" # Invalid regular expression
- "SA1001" # Invalid template
- "SA1004" # Suspiciously small untyped constant in time.Sleep
- "SA1005" # Invalid first argument to exec.Command
- "SA1006" # Printf with dynamic first argument and no further arguments
- "SA1012" # A nil context.Context is being passed to a function
- "SA1015" # Using time.Tick in a way that will leak
- "SA1019" # Using a deprecated function, variable, constant or field
- "SA1021" # Using bytes.Equal to compare two net.IP
- "SA1025" # It is not possible to use (*time.Timer).Reset's return value correctly
- "SA1027" # Atomic access to 64-bit variable must be 64-bit aligned
- "SA1029" # Inappropriate key in call to context.WithValue
- "SA2000" # sync.WaitGroup.Add called inside the goroutine
- "SA2001" # Empty critical section, did you mean to defer the unlock?
- "SA2002" # Called testing.T.FailNow or SkipNow in a goroutine
- "SA2003" # Deferred Lock right after locking
- "SA3000" # TestMain doesn't call os.Exit
- "SA3001" # Assigning to b.N in benchmarks distorts the results
- "SA4000" # Binary operator has identical expressions on both sides
- "SA4001" # &*x gets simplified to x
- "SA4006" # A value assigned to a variable is never read before being overwritten
- "SA4008" # The variable in the loop condition never changes
- "SA4009" # A function argument is overwritten before its first use
- "SA4010" # The result of append will never be observed anywhere
- "SA4011" # Break statement with no effect
- "SA4012" # Comparing a value against NaN
- "SA4013" # Negating a boolean twice (!!b)
- "SA4015" # Calling functions like math.Ceil on floats converted from integers
- "SA4016" # Certain bitwise operations, such as x ^ 0, do not do anything useful
- "SA4017" # Discarding the return values of a function without side effects
- "SA4018" # Self-assignment of variables
- "SA4020" # Unreachable case clause in a type switch
- "SA4021" # x = append(y) is equivalent to x = y
- "SA4022" # Comparing the address of a variable against nil
- "SA4023" # Impossible comparison of interface value with untyped nil
- "SA4024" # Checking for impossible return value from a builtin function
- "SA4025" # Integer division of literals that results in zero
- "SA4026" # Go constants cannot express negative zero
- "SA4027" # (*net/url.URL).Query returns a copy, modifying it doesn't change the URL
- "SA4028" # x % 1 is always zero
- "SA4029" # Ineffective attempt at sorting slice
- "SA4030" # Ineffective attempt at generating random number
- "SA4031" # Checking never-nil value against nil
- "SA5000" # Assignment to nil map
- "SA5001" # Deferring Close before checking for a possible error
- "SA5002" # The empty for loop (for {}) spins and can block the scheduler
- "SA5003" # Defers in infinite loops will never execute
- "SA5004" # for { select { ... with an empty default branch spins
- "SA5005" # The finalizer references the finalized object
- "SA5007" # Infinite recursive call
- "SA5008" # Invalid struct tag
- "SA5009" # Invalid Printf call
- "SA5010" # Impossible type assertion
- "SA5011" # Possible nil pointer dereference
- "SA5012" # Passing odd-sized slice to function expecting even size
- "SA6000" # Using regexp.Match or related in a loop
- "SA6001" # Missing an optimization opportunity when indexing maps by byte slices
- "SA6002" # Storing non-pointer values in sync.Pool allocates memory
- "SA6003" # Converting a string to a slice of runes before ranging over it
- "SA6005" # Inefficient string comparison with strings.ToLower or strings.ToUpper
- "SA6006" # Using io.WriteString to write []byte
- "SA9001" # Defers in range loops may not run when you expect them to
- "SA9002" # Using a non-octal os.FileMode that looks like it was meant to be in octal
- "SA9004" # Only the first constant has an explicit type
- "SA9005" # Trying to marshal a struct with no public fields nor custom marshaling
- "SA9006" # Dubious bit shifting of a fixed size integer value
- "SA9007" # Deleting a directory that shouldn't be deleted
- "SA9008" # else branch of a type assertion is probably not reading the right value
- "SA9009" # Ineffectual Go compiler directive
# Enable Simple checks (S1xxx) for code simplification
- "S1000" # Use plain channel send or receive instead of single-case select
- "S1001" # Replace for loop with call to copy
- "S1002" # Omit comparison with boolean constant
- "S1003" # Replace call to strings.Index with strings.Contains
- "S1004" # Replace call to bytes.Compare with bytes.Equal
- "S1005" # Drop unnecessary use of the blank identifier
- "S1006" # Use for { ... } for infinite loops
- "S1007" # Simplify regular expression by using raw string literal
- "S1008" # Simplify returning boolean expression
- "S1009" # Omit redundant nil check on slices, maps, and channels
- "S1010" # Omit default slice index
- "S1011" # Use a single append to concatenate two slices
- "S1012" # Replace time.Now().Sub(x) with time.Since(x)
- "S1016" # Use a type conversion instead of manually copying struct fields
- "S1017" # Replace manual trimming with strings.TrimPrefix
- "S1018" # Use copy for sliding elements
- "S1019" # Simplify make call by omitting redundant arguments
- "S1020" # Omit redundant nil check in type assertion
- "S1021" # Merge variable declaration and assignment
- "S1023" # Omit redundant control flow
- "S1024" # Replace x.Sub(time.Now()) with time.Until(x)
- "S1025" # Don't use fmt.Sprintf("%s", x) unnecessarily
- "S1028" # Simplify error construction with fmt.Errorf
- "S1029" # Range over the string directly
- "S1030" # Use bytes.Buffer.String or bytes.Buffer.Bytes
- "S1031" # Omit redundant nil check around loop
- "S1032" # Use sort.Ints(x), sort.Float64s(x), and sort.Strings(x)
- "S1033" # Unnecessary guard around call to delete
- "S1034" # Use result of type assertion to simplify cases
- "S1035" # Redundant call to net/http.CanonicalHeaderKey
- "S1036" # Unnecessary guard around map access
- "S1037" # Elaborate way of sleeping
- "S1038" # Unnecessarily complex way of printing formatted string
- "S1039" # Unnecessary use of fmt.Sprint
- "S1040" # Type assertion to current type
# Enable selected style checks (ST1xxx) that are valuable
- "ST1001" # Dot imports are discouraged
- "ST1005" # Incorrectly formatted error string
- "ST1006" # Poorly chosen receiver name
- "ST1008" # A function's error value should be its last return value
- "ST1011" # Poorly chosen name for variable of type time.Duration
- "ST1012" # Poorly chosen name for error variable
- "ST1013" # Should use constants for HTTP error codes, not magic numbers
- "ST1015" # A switch's default case should be the first or last case
- "ST1017" # Don't use Yoda conditions
- "ST1018" # Avoid zero-width and control characters in string literals
- "ST1019" # Importing the same package multiple times
# Enable QuickFix checks (QF1xxx) for automatic refactoring suggestions
- "QF1001" # Apply De Morgan's law
- "QF1002" # Convert untagged switch to tagged switch
- "QF1003" # Convert if/else-if chain to tagged switch
- "QF1004" # Use strings.ReplaceAll instead of strings.Replace with n == -1
- "QF1005" # Expand call to math.Pow
- "QF1006" # Lift if+break into loop condition
- "QF1007" # Merge conditional assignment into variable declaration
- "QF1008" # Omit embedded fields from selector expression
- "QF1009" # Use time.Time.Equal instead of == operator
- "QF1010" # Convert slice of bytes to string when printing it
- "QF1011" # Omit redundant type from variable declaration
- "QF1012" # Use fmt.Fprintf(x, ...) instead of x.Write(fmt.Sprintf(...))
# Configure initialisms for proper capitalization checking (ST1003)
initialisms:
# Standard Go initialisms (from Go documentation)
- "ACL"
- "API"
- "ASCII"
- "CPU"
- "CSS"
- "DNS"
- "EOF"
- "GUID"
- "HTML"
- "HTTP"
- "HTTPS"
- "ID"
- "IP"
- "JSON"
- "QPS"
- "RAM"
- "RPC"
- "SLA"
- "SMTP"
- "SQL"
- "SSH"
- "TCP"
- "TLS"
- "TTL"
- "UDP"
- "UI"
- "GID"
- "UID"
- "UUID"
- "URI"
- "URL"
- "UTF8"
- "VM"
- "XML"
- "XMPP"
- "XSRF"
- "XSS"
- "SIP"
- "RTP"
- "AMQP"
- "DB"
- "TS"
# Project-specific initialisms for GitLab and DevOps
- "CLI"
- "YAML"
- "TOML"
- "JWT"
- "OAuth"
- "GitLab"
- "MR" # Merge Request
- "PR" # Pull Request
- "CI" # Continuous Integration
- "CD" # Continuous Deployment
- "AWS" # Amazon Web Services
- "GCP" # Google Cloud Platform
- "K8s" # Kubernetes (if used)
- "RBAC" # Role-Based Access Control
- "LDAP" # Lightweight Directory Access Protocol
- "SAML" # Security Assertion Markup Language
- "SSO" # Single Sign-On
- "VCS" # Version Control System
- "SCM" # Source Code Management
- "CRUD" # Create, Read, Update, Delete
- "REST" # Representational State Transfer
- "gRPC" # gRPC Remote Procedure Call
- "SDK" # Software Development Kit
- "IDE" # Integrated Development Environment
- "OS" # Operating System
- "POSIX" # Portable Operating System Interface
# Whitelist for dot imports (ST1001) - keep empty for good practices
# Only test packages should use dot imports in very specific cases
dot-import-whitelist: []
# HTTP status codes that don't need constants (ST1013)
# Include commonly used status codes that are well-known
http-status-code-whitelist:
- "200" # OK
- "201" # Created
- "202" # Accepted
- "204" # No Content
- "301" # Moved Permanently
- "302" # Found
- "304" # Not Modified
- "400" # Bad Request
- "401" # Unauthorized
- "403" # Forbidden
- "404" # Not Found
- "405" # Method Not Allowed
- "409" # Conflict
- "410" # Gone
- "422" # Unprocessable Entity
- "429" # Too Many Requests
- "500" # Internal Server Error
- "501" # Not Implemented
- "502" # Bad Gateway
- "503" # Service Unavailable
- "504" # Gateway Timeout
exclusions:
generated: lax
rules:
- linters:
- funlen
- gocognit
- mnd
path: _test\.go
- linters:
- gochecknoinits
path: cmd/
- path: (.+)\.go$
text: Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*printf?|os\.(Un)?Setenv). is not checked
paths:
- .*\.pb\.go$
- .*_test\.go$
- vendor
- .git
- third_party$
- builtin$
- examples$
issues:
max-issues-per-linter: 0
max-same-issues: 0
formatters:
enable:
- gofmt
- goimports
settings:
goimports:
local-prefixes:
- github.com/Gosayram/gokoncurent
exclusions:
generated: lax
paths:
- .*\.pb\.go$
- .*_test\.go$
- vendor
- .git
- third_party$
- builtin$
- examples$