forked from wormhole-foundation/wormhole
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.golangci.yml
More file actions
411 lines (406 loc) · 17.5 KB
/
Copy path.golangci.yml
File metadata and controls
411 lines (406 loc) · 17.5 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
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
version: "2"
linters:
default: none
enable:
- asciicheck
# Malicious unicode characters that change the meaning are not in the source code.
- bidichk
# Ensure that the body is closed on HTTP and websocket conns
- bodyclose
- contextcheck
- depguard
# Duplicate word usage, such as 'and and' in a comment.
- dupword
- durationcheck
- errcheck
# Type assertion and comparison validation on errors. https://github.com/polyfloyd/go-errorlint
- errorlint
# Enum and maps used on switch statements are exhaustive
- exhaustive
- exhaustruct
- forbidigo
- forcetypeassert
- gocritic
- gosec
- govet
- ineffassign
- iotamixing
- loggercheck
# Check for simple misspellings of words.
- mnd
- misspell
- nilerr
- nilnesserr
- noctx
# Require explanations for nolint comments
- nolintlint
- prealloc
# Overwriting predeclared Golang names such as 'len' and 'min'.
- predeclared
# Validate common mistakes in Golang, such as invalid time.Parse format, invalid regular expression, etc.
- staticcheck
- unparam
# Unused constants, variables, functions and types
- unused
settings:
depguard:
# Rules to apply.
#
# Variables:
# - File Variables
# Use an exclamation mark `!` to negate a variable.
# Example: `!$test` matches any file that is not a go test file.
#
# `$all` - matches all go files
# `$test` - matches all go test files
#
# - Package Variables
#
# `$gostd` - matches all of go's standard library (Pulled from `GOROOT`)
#
# Default (applies if no custom rules are defined): Only allow $gostd in all files.
rules:
# Name of a rule.
main:
# Defines package matching behavior. Available modes:
# - `original`: allowed if it doesn't match the deny list and either matches the allow list or the allow list is empty.
# - `strict`: allowed only if it matches the allow list and either doesn't match the deny list or the allow rule is more specific (longer) than the deny rule.
# - `lax`: allowed if it doesn't match the deny list or the allow rule is more specific (longer) than the deny rule.
# Default: "original"
list-mode: lax
# List of file globs that will match this list of settings to compare against.
# By default, if a path is relative, it is relative to the directory where the golangci-lint command is executed.
# The placeholder '${base-path}' is substituted with a path relative to the mode defined with `run.relative-path-mode`.
# The placeholder '${config-path}' is substituted with a path relative to the configuration file.
# Default: $all
# files:
# - "!**/*_a _file.go"
# List of allowed packages.
# Entries can be a variable (starting with $), a string prefix, or an exact match (if ending with $).
# Default: []
# allow:
# List of packages that are not allowed.
# Entries can be a variable (starting with $), a string prefix, or an exact match (if ending with $).
# Default: []
deny:
# Debugging can be done without an external dependency.
- pkg: "github.com/davecgh/go-spew/spew"
desc: Use a custom formatter e.g. JSON
# Unmaintained.
- pkg: "github.com/benbjohnson/clock"
desc: deprecated
# Unnecessary for most use cases.
- pkg: "github.com/mitchellh/go-homedir"
desc: Use os.UserHomeDir()
# Unmaintained.
- pkg: "gopkg.in/godo.v2/watcher/fswatch"
desc: Use package fsnotify/fsnotify
- pkg: "github.com/pkg/errors"
desc: Should be replaced by standard lib errors package
errorlint:
errorf: false
exhaustive:
# Program elements to check for exhaustiveness.
# Default: [ switch ]
check:
- switch
- map
ignore-enum-types: "vaa.ChainID" # This type is used all over and doesn't need to be exhaustive
#default-signifies-exhaustive: true
exhaustruct:
# If empty, assume the author intended to return a struct in its default state.
# The main reason we have this rule is to prevent partial initialization.
allow-empty: true
include:
# 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: []
- .+/MessagePublication$
- .+/common\.MessagePublication$
- .+/processor\..+
exclude:
- .+/cobra\.Command$
- .+/http\.Client$
- .+/prometheus.+
forbidigo:
forbid:
- pattern: 'io\.ReadAll'
msg: "method can cause DoS for large user-controlled inputs. Use common.SafeRead instead."
- pattern: 'time\.Sleep'
msg: "time.Sleep blocks the goroutine unconditionally. Use time.After with select, context.WithTimeout, or time.Ticker instead."
exclude-godoc-examples: true
analyze-types: true
gocritic:
disabled-checks:
- assignOp
- appendAssign
- captLocal # We should probably enable this one
- commentFormatting # We should probably enable this one
- elseif
- exitAfterDefer
- ifElseChain
- sloppyLen
- underef
- unslice
# TODO: Add this later.
# gosec:
# config:
# global:
# audit: true
govet:
# The following list includes all the linters that are disabled by default.
# Uncomment any of these to enable them:
enable:
- atomic # Check for non-atomic use of sync/atomic functions
# - atomicalign # Check for non-64-bits-aligned arguments to sync/atomic functions
- deepequalerrors # Check for calls of reflect.DeepEqual on error values
- defers # Check for common mistakes in defer statements
# - fieldalignment # Find structs that would use less memory if their fields were sorted (too noisy: 200+ issues)
# - findcall # Find calls to a particular function
- ifaceassert # Detect impossible interface-to-interface assertions
- loopclosure # Check for loop variable capture in goroutines
- lostcancel # Check that context cancel functions are called
- nilness # Check for redundant or impossible nil comparisons
- reflectvaluecompare # Check for comparing reflect.Value values with == or reflect.DeepEqual
- shadow # Check for possible unintended shadowing of variables
- sigchanyzer # Check for unbuffered channels with signal.Notify
- slog # Check for invalid structured logging calls
- sortslice # Check the argument type of sort.Slice
- stringintconv # Check for string(int) conversions
- timeformat # Check for calls of (time.Time).Format or time.Parse with 2006-02-01
- unsafeptr # Check for invalid uintptr to unsafe.Pointer conversions
- unusedresult # Check for unused results of important functions
- unusedwrite # Check for unused writes
nolintlint:
# Disable to ensure that all nolint directives actually have an effect.
# Default: false
allow-unused: false
# Exclude following linters from requiring an explanation.
# Default: []
allow-no-explanation: [dupWord]
# Enable to require an explanation of nonzero length after each nolint directive.
# Default: false
require-explanation: true
# Enable to require nolint directives to mention the specific linter being suppressed.
# Default: false
require-specific: true
staticcheck:
checks:
# All of these lints should eventually be added.
# They occurred during the migration to v2 and were disabled to make the upgrade easier.
# https://golangci-lint.run/docs/linters/configuration/#staticcheck
["all", "-ST1000", "-ST1016", "-ST1020", "-ST1021", "-ST1022", "-QF1003", "-QF1006", "-QF1008", "-QF1011", "-S1009", "-ST1017", "-ST1018", "-ST1019", "-ST1023"]
unparam:
# Inspect exported functions.
#
# Set to true if no external program/library imports your code.
# XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
# if it's called for subdir of a project it can't find external interfaces. All text editor integrations
# with golangci-lint call it on a directory with the changed file.
#
# Default: false
check-exported: true
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
# node/hack/ scripts are allowed to use time.Sleep.
- linters:
- forbidigo
path: node/hack/
# This file contains hard-coded Sui core contract addresses that are marked as hardcoded credentials.
- path: pkg/txverifier/sui_test.go
text: 'G101: Potential hardcoded credentials'
- linters:
- dupword
- misspell
path: .*generated_mainnet_tokens\.go$
text: ".*" # This matches any text in the file
- linters:
- godox
path: node/hack/
# Ignore test files for these tools.
- linters:
- contextcheck
- dupWord
- exhaustruct
- nolintlint
- prealloc
path: _test\.go
- linters:
- exhaustruct
path: (?i).*mock.*
- linters:
- mnd
# NOTE: Auto-generated list of exclusions based on which files had magic number violations when this rule was added. Ideally each should be fixed.
path: node/cmd/ccq/http\.go|node/cmd/ccq/p2p\.go|node/cmd/ccq/pending_request\.go|node/cmd/ccq/query_server\.go|node/cmd/ccq/status\.go|node/cmd/ccq/utils\.go|node/cmd/guardiand/adminclient\.go|node/cmd/guardiand/adminnodes\.go|node/cmd/guardiand/admintemplate\.go|node/cmd/guardiand/node\.go|node/cmd/spy/spy\.go|node/cmd/txverifier/evm\.go|node/hack/accountant/send_obs\.go|node/hack/encrypt/encrypt\.go|node/hack/evm_test/wstest\.go|node/hack/parse_eth_tx/parse_eth_tx\.go|node/hack/query/ccqlistener/ccqlistener\.go|node/hack/query/send_req\.go|node/hack/query/utils/fetchCurrentGuardianSet\.go|node/hack/release_verification/guardian_vaa_stats\.go|node/hack/repair_eth/repair_eth\.go|node/hack/repair_solana/repair\.go|node/pkg/accountant/watcher\.go|node/pkg/adminrpc/adminserver\.go|node/pkg/altpub/alternate_pub\.go|node/pkg/common/armoredKey\.go|node/pkg/common/chainlock\.go|node/pkg/common/grpc\.go|node/pkg/common/nodekey\.go|node/pkg/common/sysutils\.go|node/pkg/db/db\.go|node/pkg/db/manager\.go|node/pkg/db/open\.go|node/pkg/devnet/hostname\.go|node/pkg/governor/devnet_config\.go|node/pkg/governor/flow_cancel_tokens\.go|node/pkg/governor/generated_mainnet_tokens\.go|node/pkg/governor/governor_monitoring\.go|node/pkg/governor/governor_prices\.go|node/pkg/governor/governor\.go|node/pkg/governor/mainnet_chains\.go|node/pkg/governor/manual_tokens\.go|node/pkg/governor/testnet_config\.go|node/pkg/guardiansigner/amazonkms\.go|node/pkg/guardiansigner/guardiansigner\.go|node/pkg/gwrelayer/gwrelayer\.go|node/pkg/manager/dogecoin/script\.go|node/pkg/manager/dogecoin/transaction\.go|node/pkg/manager/manager\.go|node/pkg/node/adminServiceRunnable\.go|node/pkg/node/publicwebRunnable\.go|node/pkg/notary/admincommands\.go|node/pkg/p2p/ccq_p2p\.go|node/pkg/p2p/netmetrics\.go|node/pkg/p2p/p2p\.go|node/pkg/processor/observation\.go|node/pkg/publicrpc/publicrpcserver\.go|node/pkg/query/query\.go|node/pkg/query/response\.go|node/pkg/supervisor/supervisor_processor\.go|node/pkg/telemetry/loki\.go|node/pkg/telemetry/prom_remote_write/format\.go|node/pkg/txverifier/evm\.go|node/pkg/txverifier/evmtypes\.go|node/pkg/txverifier/suitypes\.go|node/pkg/txverifier/utils\.go|node/pkg/watchers/algorand/watcher\.go|node/pkg/watchers/aptos/watcher\.go|node/pkg/watchers/cosmwasm/watcher\.go|node/pkg/watchers/evm/ccq_backfill\.go|node/pkg/watchers/evm/ccq\.go|node/pkg/watchers/evm/chain_config\.go|node/pkg/watchers/evm/connectors/batch_poller\.go|node/pkg/watchers/evm/connectors/block_utils\.go|node/pkg/watchers/evm/connectors/ethereum\.go|node/pkg/watchers/evm/connectors/instant_finality\.go|node/pkg/watchers/evm/custom_consistency_level\.go|node/pkg/watchers/evm/reobserve\.go|node/pkg/watchers/evm/utils\.go|node/pkg/watchers/evm/verify_chain_config/verify\.go|node/pkg/watchers/evm/watcher\.go|node/pkg/watchers/ibc/watcher\.go|node/pkg/watchers/near/finalizer\.go|node/pkg/watchers/near/nearapi/mock/mock_server\.go|node/pkg/watchers/near/nearapi/nearapi\.go|node/pkg/watchers/near/nearapi/types\.go|node/pkg/watchers/near/tx_processing\.go|node/pkg/watchers/near/watcher\.go|node/pkg/watchers/solana/client\.go|node/pkg/watchers/sui/watcher\.go|node/pkg/wormconn/clientconn\.go|node/pkg/wormconn/send_tx\.go|sdk/chainid_generator\.go|sdk/devnet_consts\.go|sdk/mainnet_consts\.go|sdk/p2p_consts\.go|sdk/testnet_consts\.go|sdk/token_bridge\.go|sdk/vaa/chainid_generated\.go|sdk/vaa/governance\.go|sdk/vaa/payloads\.go|sdk/vaa/quorum\.go|sdk/vaa/structs\.go
# ST1003 exclusions for packages that need time to migrate to CamelCase naming
# Exclude test files from ST1003 - they can be fixed separately
- linters:
- staticcheck
path: _test\.go
text: 'ST1003'
- linters:
- staticcheck
path: node/cmd/guardiand/vaa_verifier\.go
text: 'ST1003'
- linters:
- staticcheck
path: node/cmd/spy/vaa_verifier\.go
text: 'ST1003'
- linters:
- staticcheck
path: node/pkg/txverifier/.*
text: 'ST1003'
- linters:
- staticcheck
path: node/pkg/watchers/solana/.*
text: 'ST1003'
- linters:
- staticcheck
path: node/pkg/governor/.*
text: 'ST1003'
- linters:
- staticcheck
path: node/pkg/node/.*
text: 'ST1003'
- linters:
- staticcheck
path: node/cmd/guardiand/.*
text: 'ST1003'
- linters:
- staticcheck
path: node/pkg/p2p/.*
text: 'ST1003'
- linters:
- staticcheck
path: node/pkg/accountant/.*
text: 'ST1003'
- linters:
- staticcheck
path: node/pkg/query/.*
text: 'ST1003'
- linters:
- staticcheck
path: node/pkg/watchers/ibc/.*
text: 'ST1003'
- linters:
- staticcheck
path: node/pkg/watchers/near/.*
text: 'ST1003'
- linters:
- staticcheck
path: node/pkg/watchers/evm/.*
text: 'ST1003'
- linters:
- staticcheck
path: node/pkg/db/.*
text: 'ST1003'
- linters:
- staticcheck
path: node/pkg/adminrpc/.*
text: 'ST1003'
- linters:
- staticcheck
path: node/pkg/guardiansigner/.*
text: 'ST1003'
- linters:
- staticcheck
path: node/pkg/altpub/.*
text: 'ST1003'
- linters:
- staticcheck
path: node/pkg/common/.*
text: 'ST1003'
- linters:
- staticcheck
path: node/pkg/watchers/sui/.*
text: 'ST1003'
- linters:
- staticcheck
path: node/hack/.*
text: 'ST1003'
- linters:
- staticcheck
path: node/pkg/telemetry/.*
text: 'ST1003'
- linters:
- staticcheck
path: node/pkg/supervisor/.*
text: 'ST1003'
- linters:
- staticcheck
path: node/pkg/wormconn/.*
text: 'ST1003'
- linters:
- staticcheck
path: node/pkg/devnet/.*
text: 'ST1003'
- linters:
- staticcheck
path: node/pkg/publicrpc/.*
text: 'ST1003'
- linters:
- staticcheck
path: node/pkg/processor/.*
text: 'ST1003'
- linters:
- staticcheck
path: node/pkg/manager/.*
text: 'ST1003'
- linters:
- staticcheck
path: node/pkg/notary/.*
text: 'ST1003'
- linters:
- staticcheck
path: node/pkg/gwrelayer/.*
text: 'ST1003'
- linters:
- staticcheck
path: sdk/.*
text: 'ST1003'
- linters:
- staticcheck
path: node/cmd/spy/spy\.go
text: 'ST1003'
- linters:
- staticcheck
path: node/cmd/txverifier/.*
text: 'ST1003'
- linters:
- staticcheck
path: node/pkg/watchers/algorand/.*
text: 'ST1003'
- linters:
- staticcheck
path: node/pkg/watchers/aptos/.*
text: 'ST1003'
- linters:
- staticcheck
path: node/pkg/watchers/cosmwasm/.*
text: 'ST1003'
- linters:
- staticcheck
path: node/pkg/watchers/mock/.*
text: 'ST1003'
paths:
- third_party$
- builtin$
- examples$
issues:
max-issues-per-linter: 0
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
max-same-issues: 0
formatters:
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$