-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.golangci.yaml
251 lines (239 loc) · 8.97 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
linters:
enable:
- nlreturn
- err113
- decorder
- dogsled
- dupword
- errcheck
- exhaustive
- exhaustruct
- forbidigo
- funlen
- gocognit
- goconst
- gocritic
- gocyclo
- godox
- gosec
- ireturn
- nestif
- nilerr
- nilnil
- revive
- unused
linters-settings:
errcheck:
# Report about not checking of errors in type assertions: `a := b.(MyStruct)`.
# Such cases aren't reported by default.
# Default: false
check-type-assertions: true
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`.
# Such cases aren't reported by default.
# Default: false
check-blank: true
# To disable the errcheck built-in exclude list.
# See `-excludeonly` option in https://github.com/kisielk/errcheck#excluding-functions for details.
# Default: false
disable-default-exclusions: 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.
exclude-functions:
- io/ioutil.ReadFile
- io.Copy(*bytes.Buffer)
- io.Copy(os.Stdout)
exhaustruct:
# List of regular expressions to match struct packages and their names.
# Regular expressions must match complete canonical struct package/name/structname.
# If this list is empty, all structs are tested.
# Default: []
include:
- '.+\.Test'
- 'example\.com/package\.ExampleStruct[\d]{1,2}'
# List of regular expressions to exclude struct packages and their names from checks.
# Regular expressions must match complete canonical struct package/name/structname.
# Default: []
exclude:
- '.+/cobra\.Command$'
forbidigo:
# Forbid the following identifiers (list of regexp).
# Default: ["^(fmt\\.Print(|f|ln)|print|println)$"]
forbid:
# Built-in bootstrapping functions.
- ^print(ln)?$
# Optional message that gets included in error reports.
# - p: ^fmt\.Print.*$
# msg: Do not commit print statements.
# Alternatively, put messages at the end of the regex, surrounded by `(# )?`
# Escape any special characters. Those messages get included in error reports.
# - 'fmt\.Print.*(# Do not commit print statements\.)?'
# Forbid spew Dump, whether it is called as function or method.
# Depends on analyze-types below.
- ^spew\.(ConfigState\.)?Dump$
# The package name might be ambiguous.
# The full import path can be used as additional criteria.
# Depends on analyze-types below.
- p: ^v1.Dump$
pkg: ^example.com/pkg/api/v1$
# Exclude godoc examples from forbidigo checks.
# Default: true
exclude-godoc-examples: false
# Instead of matching the literal source code,
# use type information to replace expressions with strings that contain the package name
# and (for methods and fields) the type name.
# This makes it possible to handle import renaming and forbid struct fields and methods.
# Default: false
analyze-types: true
ireturn:
# List of interfaces to allow.
# Lists of the keywords and regular expressions matched to interface or package names can be used.
# `allow` and `reject` settings cannot be used at the same time.
#
# Keywords:
# - `empty` for `interface{}`
# - `error` for errors
# - `stdlib` for standard library
# - `anon` for anonymous interfaces
# - `generic` for generic interfaces added in go 1.18
#
# Default: [anon, error, empty, stdlib]
allow:
- anon
- generic
- empty
- error
# You can specify idiomatic endings for interface
- (or|er)$
# List of interfaces to reject.
# Lists of the keywords and regular expressions matched to interface or package names can be used.
# `allow` and `reject` settings cannot be used at the same time.
#
# Keywords:
# - `empty` for `interface{}`
# - `error` for errors
# - `stdlib` for standard library
# - `anon` for anonymous interfaces
# - `generic` for generic interfaces added in go 1.18
#
# Default: []
reject:
# - github.com\/user\/package\/v4\.Type
nlreturn:
# Size of the block (including return statement that is still "OK")
# so no return split required.
# Default: 1
block-size: 2
gocognit:
# Minimal code complexity to report.
# Default: 30 (but we recommend 10-20)
min-complexity: 20
goconst:
# Minimal length of string constant.
# Default: 3
min-len: 3
# Minimum occurrences of constant string count to trigger issue.
# Default: 3
min-occurrences: 3
# Ignore test files.
# Default: false
ignore-tests: true
# Look for existing constants matching the values.
# Default: true
match-constant: false
# Search also for duplicated numbers.
# Default: false
numbers: true
# Minimum value, only works with goconst.numbers
# Default: 3
min: 2
# Maximum value, only works with goconst.numbers
# Default: 3
max: 2
# Ignore when constant is not used as function argument.
# Default: true
ignore-calls: false
# Exclude strings matching the given regular expression.
# Default: ""
ignore-strings: 'foo.+'
gocyclo:
# Minimal code complexity to report.
# Default: 30 (but we recommend 10-20)
min-complexity: 20
nestif:
# Minimal complexity of if statements to report.
# Default: 5
min-complexity: 4
nilnil:
# In addition, detect opposite situation (simultaneous return of non-nil error and valid value).
# Default: false
detect-opposite: true
# List of return types to check.
# Default: ["chan", "func", "iface", "map", "ptr", "uintptr", "unsafeptr"]
checked-types:
- chan
- func
- iface
- map
- ptr
- uintptr
- unsafeptr
wsl:
# Do strict checking when assigning from append (x = append(x, y)).
# If this is set to true - the append call must append either a variable
# assigned, called or used on the line above.
# https://github.com/bombsimon/wsl/blob/master/doc/configuration.md#strict-append
# Default: true
strict-append: false
# Allows assignments to be cuddled with variables used in calls on
# line above and calls to be cuddled with assignments of variables
# used in call on line above.
# https://github.com/bombsimon/wsl/blob/master/doc/configuration.md#allow-assign-and-call
# Default: true
allow-assign-and-call: false
# Allows assignments to be cuddled with anything.
# https://github.com/bombsimon/wsl/blob/master/doc/configuration.md#allow-assign-and-anything
# Default: false
allow-assign-and-anything: true
# Allows cuddling to assignments even if they span over multiple lines.
# https://github.com/bombsimon/wsl/blob/master/doc/configuration.md#allow-multiline-assign
# Default: true
allow-multiline-assign: false
# If the number of lines in a case block is equal to or lager than this number,
# the case *must* end white a newline.
# https://github.com/bombsimon/wsl/blob/master/doc/configuration.md#force-case-trailing-whitespace
# Default: 0
force-case-trailing-whitespace: 1
# Allow blocks to end with comments.
# https://github.com/bombsimon/wsl/blob/master/doc/configuration.md#allow-trailing-comment
# Default: false
allow-trailing-comment: true
# Allow multiple comments in the beginning of a block separated with newline.
# https://github.com/bombsimon/wsl/blob/master/doc/configuration.md#allow-separated-leading-comment
# Default: false
allow-separated-leading-comment: true
# Allow multiple var/declaration statements to be cuddled.
# https://github.com/bombsimon/wsl/blob/master/doc/configuration.md#allow-cuddle-declarations
# Default: false
allow-cuddle-declarations: true
# A list of call idents that everything can be cuddled with.
# Defaults: [ "Lock", "RLock" ]
allow-cuddle-with-calls: ["Foo", "Bar"]
# AllowCuddleWithRHS is a list of right hand side variables that is allowed
# to be cuddled with anything.
# Defaults: [ "Unlock", "RUnlock" ]
allow-cuddle-with-rhs: ["Foo", "Bar"]
# Causes an error when an If statement that checks an error variable doesn't
# cuddle with the assignment of that variable.
# https://github.com/bombsimon/wsl/blob/master/doc/configuration.md#force-err-cuddling
# Default: false
force-err-cuddling: true
# When force-err-cuddling is enabled this is a list of names
# used for error variables to check for in the conditional.
# Default: [ "err" ]
error-variable-names: ["foo"]
# Causes an error if a short declaration (:=) cuddles with anything other than
# another short declaration.
# This logic overrides force-err-cuddling among others.
# https://github.com/bombsimon/wsl/blob/master/doc/configuration.md#force-short-decl-cuddling
# Default: false
force-short-decl-cuddling: true