-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.golangci.yaml
More file actions
383 lines (360 loc) · 13.1 KB
/
.golangci.yaml
File metadata and controls
383 lines (360 loc) · 13.1 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
---
version: "2"
# Options for analysis running.
run:
# Number of operating system threads (`GOMAXPROCS`) that can execute golangci-lint simultaneously.
# If it is explicitly set to 0 (i.e. not the default) then golangci-lint will automatically set the value to match Linux container CPU quota.
# Default: the number of logical CPUs in the machine
concurrency: 12
# Timeout for analysis, e.g. 30s, 5m.
# Default: 1m
timeout: 5m
# Exit code when at least one issue was found.
# Default: 1
issues-exit-code: 2
# Include test files or not.
# Default: true
tests: false
# List of build tags, all linters use it.
# Default: []
# build-tags:
# - tag
# If set, we pass it to "go list -mod={option}". From "go help modules":
# If invoked with -mod=readonly, the go command is disallowed from the implicit
# automatic updating of go.mod described above. Instead, it fails when any changes
# to go.mod are needed. This setting is most useful to check that go.mod does
# not need updates, such as in a continuous integration and testing system.
# If invoked with -mod=vendor, the go command assumes that the vendor
# directory holds the correct copies of dependencies and ignores
# the dependency descriptions in go.mod.
#
# Allowed values: readonly|vendor|mod
# Default: ""
modules-download-mode: readonly
# Allow multiple parallel golangci-lint instances running.
# If false, golangci-lint acquires file lock on start.
# Default: false
allow-parallel-runners: true
# Allow multiple golangci-lint instances running, but serialize them around a lock.
# If false, golangci-lint exits with an error if it fails to acquire file lock on start.
# Default: false
allow-serial-runners: true
# Define the Go version limit.
# Mainly related to generics support since go1.18.
# Default: use Go version from the go.mod file, fallback on the env var `GOVERSION`, fallback on 1.17
go: "1.26.2"
linters:
# Enable specific linter
# https://golangci-lint.run/usage/linters/#enabled-by-default
default: all
enable:
- wsl_v5
disable:
- exhaustruct
- depguard
- ireturn
- lll
- tagliatelle
- wsl
settings:
cyclop:
# The maximal code complexity to report.
# Default: 10
max-complexity: 12
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: false
# 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:
- fmt.Fprintf
- fmt.Fprintln
funlen:
lines: 100
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.
# Default: 120.
line-length: 150
# Tab width in spaces.
# Default: 1
tab-width: 1
mnd:
ignored-numbers:
- "0666"
- "0755"
- "2"
ireturn:
# ireturn does not allow using `allow` and `reject` settings at the same time.
# Both settings are lists of the keywords and regular expressions matched to interface or package names.
# keywords:
# - `empty` for `any`
# - `error` for errors
# - `stdlib` for standard library
# - `anon` for anonymous interfaces
# - `generic` for generic interfaces added in go 1.18
# By default, it allows using errors, empty interfaces, anonymous interfaces,
# and interfaces provided by the standard library.
allow:
- anon
- error
- empty
- stdlib
# You can specify idiomatic endings for interface
- (or|er|ry)$
revive:
enable-all-rules: true
rules:
- name: add-constant
severity: warning
disabled: false
arguments:
- max-lit-count: "3"
allow-strs: '"","get","path","key"'
allow-ints: "-1,0,1,2,10"
allow-floats: "0.0,1.0"
- name: cognitive-complexity
severity: warning
disabled: false
arguments: [15]
- name: cyclomatic
arguments: [15]
# - name: function-length
# arguments: [80, 0]
- name: max-public-structs
arguments: [10]
- name: nested-structs
disabled: true
- name: flag-parameter
disabled: true
- name: line-length-limit
arguments: [160]
- name: var-naming
disabled: true
wsl_v5:
# Allow cuddling a variable if it's used first in the immediate following block,
# even if the statement with the block doesn't use the variable.
# https://github.com/bombsimon/wsl/tree/main?tab=readme-ov-file#configuration
# Default: true
allow-first-in-block: false
# Same as above,
# but allows cuddling if the variable is used anywhere in the following (or nested) block.
# https://github.com/bombsimon/wsl/tree/main?tab=readme-ov-file#configuration
# Default: false
allow-whole-block: true
# If a block contains more than this number of lines,
# the branch statement needs to be separated by whitespace.
# https://github.com/bombsimon/wsl/tree/main?tab=readme-ov-file#configuration
# Default: 2
branch-max-lines: 4
# If set to a non-negative number,
# case blocks need to end with whitespace if exceeding this number
# https://github.com/bombsimon/wsl/tree/main?tab=readme-ov-file#configuration
# Default: 0
case-max-lines: 2
# Default checks to use.
# Can be `all`, `none`, `default` or empty.
# https://github.com/bombsimon/wsl/tree/main?tab=readme-ov-file#checks-and-configuration
# Default: ""
default: all
enable:
- assign
- branch
- decl
- defer
- expr
- for
- go
- if
- inc-dec
- label
- range
- return
- select
- send
- switch
- type-switch
- append
- assign-exclusive
- assign-expr
- err
- leading-whitespace
- trailing-whitespace
wrapcheck:
# An array of strings that specify globs of packages to ignore.
# Default: []
ignore-package-globs:
- github.com/hyp3rd/*
- github.com/gofiber/fiber/*
varnamelen:
# The longest distance, in source lines, that is being considered a "small scope".
# Variables used in at most this many lines will be ignored.
# Default: 5
max-distance: 6
# The minimum length of a variable's name that is considered "long".
# Variable names that are at least this long will be ignored.
# Default: 3
min-name-length: 2
# Check method receivers.
# Default: false
check-receiver: false
# Check named return values.
# Default: false
check-return: true
# Check type parameters.
# Default: false
check-type-param: true
# Ignore "ok" variables that hold the bool return value of a type assertion.
# Default: false
ignore-type-assert-ok: true
# Ignore "ok" variables that hold the bool return value of a map index.
# Default: false
ignore-map-index-ok: true
# Ignore "ok" variables that hold the bool return value of a channel receive.
# Default: false
ignore-chan-recv-ok: true
# Optional list of variable names that should be ignored completely.
# Default: []
ignore-names:
- err
# Optional list of variable declarations that should be ignored completely.
# Entries must be in one of the following forms (see below for examples):
# - for variables, parameters, named return values, method receivers, or type parameters:
# <name> <type> (<type> can also be a pointer/slice/map/chan/...)
# - for constants: const <name>
#
# Default: []
ignore-decls:
- c echo.Context
- t testing.T
- f *foo.Bar
- e error
- i int
- const C
- r *http.Request
- w http.ResponseWriter
- T any
- T backend.IBackendConstrain
- m map[string]int
formatters:
enable:
# - gci
- gofumpt
- goimports
- golines
# gci:
# # Section configuration to compare against.
# # Section names are case-insensitive and may contain parameters in ().
# # The default order of sections is `standard > default > custom > blank > dot > alias > localmodule`,
# # If `custom-order` is `true`, it follows the order of `sections` option.
# # Default: ["standard", "default"]
# sections:
# - standard # Standard section: captures all standard packages.
# - default # Default section: contains all imports that could not be matched to another section type.
# - prefix(github.com/hyp3rd/ewrap) # Custom section: groups all imports with the specified Prefix.
# # Checks that no inline comments are present.
# # Default: false
# no-inline-comments: false
# # Checks that no prefix comments (comment lines above an import) are present.
# # Default: false
# no-prefix-comments: false
# # Enable custom order of sections.
# # If `true`, make the section order the same as the order of `sections`.
# # Default: false
# custom-order: true
# # Drops lexical ordering for custom sections.
# # Default: false
# no-lex-order: false
settings:
gci:
# Section configuration to compare against.
# Section names are case-insensitive and may contain parameters in ().
# The default order of sections is `standard > default > custom > blank > dot > alias > localmodule`.
# If `custom-order` is `true`, it follows the order of `sections` option.
# Default: ["standard", "default"]
sections:
- standard # Standard section: captures all standard packages.
- default # Default section: contains all imports that could not be matched to another section type.
- prefix(github.com/hyp3rd/*) # Custom section: groups all imports with the specified Prefix.
- blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled.
- dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled.
- alias # Alias section: contains all alias imports. This section is not present unless explicitly enabled.
- localmodule # Local module section: contains all local packages. This section is not present unless explicitly enabled.
# Checks that no inline comments are present.
# Default: false
no-inline-comments: true
# Checks that no prefix comments (comment lines above an import) are present.
# Default: false
no-prefix-comments: true
# Enable custom order of sections.
# If `true`, make the section order the same as the order of `sections`.
# Default: false
custom-order: true
# Drops lexical ordering for custom sections.
# Default: false
no-lex-order: true
gofumpt:
# Module path which contains the source code being formatted.
# Default: ""
module-path: github.com/hyp3rd/hypercache
# Choose whether to use the extra rules.
# Default: false
extra-rules: true
goimports:
# A list of prefixes, which, if set, checks import paths
# with the given prefixes are grouped after 3rd-party packages.
# Default: []
local-prefixes:
- github.com/hyp3rd/*
- <module-path>
golines:
# Target maximum line length.
# Default: 100
max-len: 140
# Length of a tabulation.
# Default: 4
# tab-len: 8
# Shorten single-line comments.
# Default: false
shorten-comments: true
# Default: true
reformat-tags: true
# Split chained methods on the dots as opposed to the arguments.
# Default: true
chain-split-dots: true
# output configuration options
output:
# Order to use when sorting results.
# Require `sort-results` to `true`.
# Possible values: `file`, `linter`, and `severity`.
#
# If the severity values are inside the following list, they are ordered in this order:
# 1. error
# 2. warning
# 3. high
# 4. medium
# 5. low
# Either they are sorted alphabetically.
#
# Default: ["file"]
sort-order:
- linter
- severity
- file # filepath, line, and column.
# Show statistics per linter.
# Default: false
show-stats: true
issues:
# Make issues output unique by line.
# Default: true
uniq-by-line: false