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
240 lines (235 loc) · 9.61 KB
/
.golangci.yml
File metadata and controls
240 lines (235 loc) · 9.61 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
version: "2"
linters:
default: none
enable:
# 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.
- 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:
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: []
- ./+governor.tokenConfigEntry$
# TODO: MessagePublications _should_ be exhaustive but this will require many changes.
- ./_common.MessagePublication$
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."
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
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/usage/linters/#staticcheck
["all", "-ST1000", "-ST1003", "-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:
# 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
path: _test\.go
- linters:
- exhaustruct
path: (?i).*mock.*
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$