-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Expand file tree
/
Copy path.golangci.yml
More file actions
337 lines (280 loc) · 8.87 KB
/
.golangci.yml
File metadata and controls
337 lines (280 loc) · 8.87 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
version: "2"
run:
# If you change this please also update GO_VERSION in Makefile (then run
# `make lint` to see where else it needs to be updated as well).
go: "1.25.5"
# Abort after 10 minutes.
timeout: 10m
build-tags:
- autopilotrpc
- chainrpc
- dev
- invoicesrpc
- neutrinorpc
- peersrpc
- signrpc
- walletrpc
- watchtowerrpc
- kvdb_etcd
- kvdb_postgres
- kvdb_sqlite
- integration
linters:
default: all
disable:
# We instead use our own custom line length linter called `ll` since
# then we can ignore log lines.
- lll
# Global variables are used in many places throughout the code base.
- gochecknoglobals
# We want to allow short variable names.
- varnamelen
# We want to allow TODOs.
- godox
# Instances of table driven tests that don't pre-allocate shouldn't trigger
# the linter.
- prealloc
# Init functions are used by loggers throughout the codebase.
- gochecknoinits
# Deprecated linters. See https://golangci-lint.run/usage/linters/.
- bodyclose
- contextcheck
- nilerr
- noctx
- rowserrcheck
- sqlclosecheck
- tparallel
- unparam
- wastedassign
# Disable whitespace linters as it has conflict rules against our
# contribution guidelines.
- wsl
- wsl_v5
# Allow using default empty values.
- exhaustruct
# Allow exiting case select faster by putting everything in default.
- exhaustive
# Allow tests to be put in the same package.
- testpackage
# Don't run the cognitive related linters.
- gocognit
- gocyclo
- maintidx
- cyclop
# Allow customized interfaces to be returned from functions.
- ireturn
# Disable too many blank identifiers check. We won't be able to run this
# unless a large refactor has been applied to old code.
- dogsled
# We don't wrap errors.
- wrapcheck
# Allow dynamic errors.
- err113
# We use ErrXXX instead.
- errname
# Disable nil check to allow returning multiple nil values.
- nilnil
# We often split tests into separate test functions. If we are forced to
# call t.Helper() within those functions, we lose the information where
# exactly a test failed in the generated failure stack trace.
- thelper
# The linter is too aggressive and doesn't add much value since reviewers
# will also catch magic numbers that make sense to extract.
- mnd
# Some of the tests cannot be parallelized. On the other hand, we don't
# gain much performance with this check so we disable it for now until
# unit tests become our CI bottleneck.
- paralleltest
# New linters that we haven't had time to address yet.
- testifylint
- perfsprint
- inamedparam
- copyloopvar
- tagalign
- protogetter
- revive
- depguard
- gosmopolitan
- intrange
- goconst
# Disable function order linter because we structure exported and unexported
# functions differently.
- funcorder
# Disable noinlineerr linter because we use it to inline errors.
- noinlineerr
# Disable embeddedstructfieldcheck linter because we use it to align
# structs. Because sometimes we have atomic fields that need to be aligned
# with means we need to assure that the field is at the beginning of the
# struct.
- embeddedstructfieldcheck
settings:
dupl:
# Tokens count to trigger issue.
threshold: 200
errorlint:
# Check for incorrect fmt.Errorf error wrapping.
errorf: true
funlen:
# Checks the number of lines in a function.
# If lower than 0, disable the check.
lines: 200
# Checks the number of statements in a function.
statements: 80
gomoddirectives:
# See project's go.mod for the explanation why these are needed.
replace-allow-list:
- github.com/ulikunitz/xz
- github.com/gogo/protobuf
- google.golang.org/protobuf
- github.com/lightningnetwork/lnd/sqldb
- github.com/lightningnetwork/lightning-onion
replace-local: true
gosec:
excludes:
- G402 # Look for bad TLS connection settings.
- G306 # Poor file permissions used when writing to a new file.
- G601 # Implicit memory aliasing in for loop.
- G115 # Integer overflow in conversion.
nestif:
# Minimal complexity of if statements to report.
min-complexity: 10
nlreturn:
# Size of the block (including return statement that is still "OK")
# so no return split required.
block-size: 3
staticcheck:
checks:
- -SA1019
tagliatelle:
case:
rules:
json: snake
usetesting:
context-background: true
whitespace:
multi-if: true
multi-func: true
custom:
ll:
type: module
description: Custom lll linter with 'S' log line exclusion.
settings:
# Max line length, lines longer will be reported.
line-length: 80
# The regex that we will use to detect the start of an `S` log line.
log-regex: ^\s*.*(L|l)og\.(Info|Debug|Trace|Warn|Error|Critical)S\(
# Tab width in spaces.
tab-width: 8
exclusions:
# Mode of the generated files analysis.
#
# - `strict`: sources are excluded by strictly following the Go generated file convention.
# Source files that have lines matching only the following regular expression will be excluded: `^// Code generated .* DO NOT EDIT\.$`
# This line must appear before the first non-comment, non-blank text in the file.
# https://go.dev/s/generatedcode
# - `lax`: sources are excluded if they contain lines like `autogenerated file`, `code generated`, `do not edit`, etc.
# - `disable`: disable the generated files exclusion.
#
# Default: strict
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
# Allow duplications in tests so it's easier to follow a single unit
- dupl
- funlen
- gosec
- revive
# Exclude gosec from running for tests so that tests with weak
# randomness (math/rand) will pass the linter.
path: _test\.go
- linters:
# forcetypeassert is skipped for the mock because the test would fail
# if the returned value doesn't match the type, so there's no need to
# check the convert.
- forcetypeassert
- revive
path: mock*
- linters:
- funlen
- gosec
path: test*
# Allow duplicated code and fmt.Printf() in DB migrations.
- linters:
- dupl
- forbidigo
- godot
path: channeldb/migration*
# Allow duplicated code and fmt.Printf() in DB migration tests.
- linters:
- dupl
- forbidigo
- godot
path: channeldb/migtest
# Allow fmt.Printf() in commands.
- linters:
- forbidigo
path: cmd/commands/*
# Allow fmt.Printf() in config parsing.
- linters:
- forbidigo
path: config\.go
- linters:
- forbidigo
path: lnd\.go
- linters:
# forcetypeassert is skipped for the mock because the test would fail
# if the returned value doesn't match the type, so there's no need to
# check the convert.
- forcetypeassert
path: lnmock/*
- linters:
# forcetypeassert is skipped for the mock because the test would fail
# if the returned value doesn't match the type, so there's no need to
# check the convert.
- forcetypeassert
path: mock*
# Skip autogenerated files for mobile and gRPC as well as copied code for
# internal use.
paths:
- third_party$
- builtin$
- examples$
- "mobile\\/.*generated\\.go"
- "\\.pb\\.go$"
- "\\.pb\\.gw\\.go$"
- "internal\\/musig2v040"
- channeldb/migration_01_to_11
- channeldb/migration/lnwire21
- payments/db/migration1/lnwire
- payments/db/migration1/record
issues:
# Only show newly introduced problems.
new-from-rev: 03eab4db64540aa5f789c617793e4459f4ba9e78
formatters:
enable:
- gci
- gofmt
- goimports
settings:
gofmt:
# simplify code: gofmt with `-s` option, true by default
simplify: true
exclusions:
generated: lax
# Skip autogenerated files for mobile and gRPC as well as copied code for
# internal use.
paths:
- third_party$
- builtin$
- examples$
- "mobile\\/.*generated\\.go"
- "\\.pb\\.go$"
- "\\.pb\\.gw\\.go$"
- "internal\\/musig2v040"
- channeldb/migration_01_to_11
- channeldb/migration/lnwire21