-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy path.golangci.yml
More file actions
268 lines (224 loc) · 7.23 KB
/
Copy path.golangci.yml
File metadata and controls
268 lines (224 loc) · 7.23 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
version: "2"
run:
go: "1.25.3"
# Abort after 10 minutes.
timeout: 10m
build-tags:
- test_postgres
- test_sqlite
- systest
linters:
default: all
settings:
custom:
ll:
type: "module"
description: "Custom lll linter with log line exclusion."
settings:
# Max line length, lines longer will be reported.
line-length: 80
# Tab width in spaces.
tab-width: 8
# The regex that we will use to detect the start of a log line.
log-regex: "^\\s*.*(L|l)og\\."
errorlint:
# Check for incorrect fmt.Errorf error wrapping.
errorf: true
tagliatelle:
case:
rules:
json: snake
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.
staticcheck:
checks: ["-SA1019"]
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
dupl:
# Tokens count to trigger issue.
threshold: 200
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
exhaustive:
# Treat switches with a `default:` clause as exhaustive. The
# codebase's convention is to use `default: return err` to handle
# unknown enum values defensively; requiring every proto enum
# variant to be listed explicitly would add no safety and create
# large diffs when protos evolve.
default-signifies-exhaustive: true
gomoddirectives:
replace-local: true
replace-allow-list:
# Allow forked migrate package.
- github.com/golang-migrate/migrate/v4
# Allow forked protobuf for hex display support.
- google.golang.org/protobuf
# Allow btcwallet to follow the 0.21 lnd/lndclient stack while
# taproot-assets still requires the released v0.16.17 tag.
- github.com/btcsuite/btcwallet
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
# Disabled pending a larger cleanup PR.
- noctx
- tparallel
- unparam
# Disable whitespace linter as it has conflict rules against our
# contribution guidelines.
- wsl
# llformat now owns vertical whitespace for handwritten Go. The
# whitespace linter cannot express the project rule that multi-line
# function signatures keep a body separator while single-return control
# blocks stay compact.
- whitespace
# Allow using default empty values.
- exhaustruct
# 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
- embeddedstructfieldcheck
- funcorder
- modernize
- noinlineerr
- gosmopolitan
- intrange
- goconst
- wsl_v5
exclusions:
generated: lax
paths:
- "\\.pb\\.go$"
- "\\.pb\\.gw\\.go$"
- "db/sqlc/.*\\.go$"
rules:
# Exclude gosec from running for tests so that tests with weak randomness
# (math/rand) will pass the linter.
- path: _test\.go
linters:
- gosec
- funlen
- revive
# Allow duplications in tests so it's easier to follow a single unit
# test.
- dupl
- path: mock*
linters:
- revive
# 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: test*
linters:
- gosec
- funlen
# Allow duplicated code and fmt.Printf() in DB migrations.
- path: db/.*migration*
linters:
- dupl
- forbidigo
- godot
# Template files contain raw template text with long lines that
# represent generated code shape and cannot be wrapped.
- path: cmd/protoc-gen-mailboxrpc/internal/gen/templates\.go
linters:
- ll
# Test harness has some special rules. errcheck is disabled here
# because the harness has many best-effort Close/cleanup calls on
# Docker containers and gRPC conns where the error is not
# actionable.
- path: harness
linters:
- forbidigo
- tagliatelle
- errcheck
# Test harness config/helpers write to tempdirs, read macaroons
# from variable paths, and make HTTP requests to regtest services.
# These trip gosec but are safe in the test-infra context.
- path: harness
linters:
- gosec
text: "G301|G302|G304|G704"
# Allow fmt.Printf() in commands.
- path: cmd/.*/main\.go
linters:
- forbidigo
# The wavecli CLI uses defer conn.Close() and fmt.Fprintln to
# stdout throughout. Unchecked errors there are not actionable
# (the process is about to exit anyway).
- path: cmd/wavecli/
linters:
- errcheck
formatters:
settings:
gofmt:
# simplify code: gofmt with `-s` option, true by default.
simplify: true
exclusions:
generated: lax
paths:
- "\\.pb\\.go$"
- "\\.pb\\.gw\\.go$"
- "db/sqlc/.*\\.go$"