forked from bufbuild/buf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.golangci.yml
284 lines (283 loc) · 9.67 KB
/
.golangci.yml
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
linters-settings:
errcheck:
check-type-assertions: true
forbidigo:
forbid:
# Use private/pkg/thread.Parallelize
- '^errgroup\.'
# Use private/pkg/command.Runner
- '^exec\.Cmd$'
- '^exec\.Command$'
- '^exec\.CommandContext$'
# os.Rename does not work across filesystem boundaries
# See https://github.com/bufbuild/buf/issues/639
- '^os\.Rename$'
# Use private/pkg/osext.Getwd
- '^os\.Getwd$'
# Use private/pkg/osext.Chdir
- '^os\.Chdir$'
# Ban debug statements
- '^fmt\.Print'
- '^log\.'
- '^print$'
- '^println$'
govet:
enable:
- nilness
importas:
alias:
- pkg: github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/image/v1
alias: imagev1
- pkg: github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/module/v1
alias: modulev1
- pkg: github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1
alias: registryv1alpha1
nolintlint:
allow-unused: false
allow-no-explanation: []
require-explanation: true
require-specific: true
linters:
enable:
- asciicheck
- bidichk
- bodyclose
- containedctx
# - contextcheck
- decorder
# - depguard
- dogsled
- errcheck
- exhaustruct
- exportloopref
- forbidigo
- forcetypeassert
- gci
- gochecknoinits
- gofmt
- goheader
# - goimports
- gomodguard
- goprintffuncname
- gosec
- gosimple
- govet
- grouper
- importas
- ineffassign
- loggercheck
- makezero
- mirror
- misspell
- nakedret
- nilerr
- nolintlint
- nosprintfhostport
- paralleltest
- predeclared
- promlinter
- reassign
- rowserrcheck
- staticcheck
- stylecheck
- typecheck
- unconvert
- unused
- wastedassign
- whitespace
disable-all: true
issues:
exclude-dirs-use-default: false
exclude-rules:
# We didn't turn on exhaustruct historically, but we really want to make sure it is turned on
# for this file, as we do conversion between v1beta1 and v1 registry-proto types.
- path-except: private/bufpkg/bufmodule/bufmoduleapi/convert.go
linters:
- exhaustruct
- linters:
- gosec
# G101 checks for hardcoded credentials, and the variables named "*Password*
# trip this off.
path: private/buf/bufcli/env.go
text: "G101:"
- linters:
- containedctx
# Type must implement an interface whose methods do not accept context. But this
# implementation makes RPC calls, which need a context. So we allow creator of the
# type to provide a context at value creation (instead of using context.Background()).
path: private/buf/bufcurl/reflection_resolver.go
- linters:
- gosec
# We verify manually so that we can emit verbose output while doing so.
path: private/buf/bufcurl/tls.go
text: "G402:"
- linters:
- paralleltest
# This test shouldn't run in parallel as it needs osext.Getwd.
path: private/buf/buffetch/internal/reader_test.go
text: "missing the call to method parallel"
- linters:
- paralleltest
# Parallelizing TestPlainPostHandlerTLS and TestPlainPostHandlerH2C
# makes this test flaky.
path: private/buf/bufstudioagent/bufstudioagent_test.go
text: "missing the call to method parallel"
- linters:
- paralleltest
# TestWorkspaceArchiveDir, TestWorkspaceWithInvalidArchivePathFail
# and TestWorkspaceWithInvalidArchiveAbsolutePathFail cannot run in parallel
# because they all call createZipFromDir on the same path, writing to the same file.
path: private/buf/cmd/buf/workspace_test.go
text: "missing the call to method parallel"
- linters:
- forbidigo
# This is a legacy usage of os.Getwd we're not bothering to port yet.
path: private/buf/cmd/buf/command/alpha/protoc/protoc_test.go
text: "os.Getwd"
- linters:
- dogsled
# One function call doesn't care about most of the returned destructured values. The
# dogsled linter complains about it. (Value of this linter is unclear...)
path: private/buf/cmd/buf/command/curl/curl.go
- linters:
- forbidigo
# This is a legacy usage of os.Getwd we're not bothering to port yet.
path: private/buf/cmd/buf/command/generate/generate_test.go
text: "os.Getwd"
- linters:
- gochecknoinits
# we actually want to use this init to create a protovalidate.Validator
path: private/bufpkg/bufcas/proto.go
- linters:
- staticcheck
text: "GetIgnoreEmpty is deprecated"
path: private/bufpkg/bufcheck/buflint/internal/buflintvalidate/field.go
- linters:
- staticcheck
text: "GetSkipped is deprecated"
path: private/bufpkg/bufcheck/buflint/internal/buflintvalidate/field.go
- linters:
- gochecknoinits
# we actually want to use init here
path: private/bufpkg/bufconfig/module_config.go
- linters:
- gosec
# We don't need a cryptographically secure RNG for these tests, and a
# deterministic RNG is actually nice for test repeatability.
path: private/bufpkg/bufimage/bufimageutil/.*_test\.go
text: "G404:"
- linters:
- paralleltest
# This test shouldn't run in parallel as it allocates a lot of memory.
path: private/bufpkg/bufimage/build_image_unix_test.go
text: "missing the call to method parallel"
- linters:
- containedctx
# we actually want to embed a context here
path: private/bufpkg/bufimage/parser_accessor_handler.go
- linters:
- containedctx
# we actually want to embed a context here
path: private/bufpkg/bufmodule/module.go
- linters:
- containedctx
# we actually want to embed a context here
path: private/bufpkg/bufmodule/module_set_builder.go
- linters:
- gochecknoinits
# we actually want to use init here
path: private/bufpkg/bufmodule/paths.go
- linters:
- forbidigo
# we want to use errgroup here
path: private/bufpkg/bufremoteplugin/bufremoteplugindocker/docker.go
text: "use of `errgroup"
- linters:
- forbidigo
# this is one of two files we want to allow exec.Cmd functions in
path: private/pkg/command/process.go
- linters:
- forbidigo
# this is one of two files we want to allow exec.Cmd functions in
path: private/pkg/command/runner.go
- linters:
- gosec
# G204 checks that exec.Command is not called with non-constants.
path: private/pkg/command/runner.go
text: "G204:"
- linters:
- gosec
# We should be able to use net/http/cgi in a unit test, in addition the CVE mentions
# only versions of go < 1.6.3 are affected.
path: private/pkg/git/git_test.go
text: "G504:"
- linters:
- wastedassign
# netrc/internal is a library largely copied in from an external repository with attribution.
# We try to make minimal edits.
path: private/pkg/netrc/internal/internal.go
- linters:
- forbidigo
# We cache os.Getwd in osext, osext is the entrypoint.
path: private/pkg/osext/osext.go
text: "os.Getwd"
- linters:
- forbidigo
# We cache os.Getwd in osext, osext has a Chdir that clears the cache.
path: private/pkg/osext/osext.go
text: "os.Chdir"
- linters:
- gochecknoinits
# protoencoding calls detrand.Disable via go:linkname and and init function. See the comments
# in the file for more details.
path: private/pkg/protoencoding/detrand.go
- linters:
- errcheck
# headers.go has casts with values from contexts that should fail if there
# is no error, but it would be very unidiomatic to return an error from
# the functions that do these casts, and we completely control the
# context values within this file
path: private/pkg/rpc/headers.go
- linters:
- forbidigo
# we use os.Rename here to rename files in the same directory
# This is safe (we aren't traversing filesystem boundaries).
path: private/pkg/storage/storageos/bucket.go
text: "os.Rename"
- linters:
- containedctx
# we actually want to embed a context here
path: private/pkg/transport/grpc/grpcclient/client_conn_provider.go
- linters:
- forbidigo
# we actually want to use errgroup when starting an HTTP server
path: private/pkg/transport/http/httpserver/httpserver.go
- linters:
- stylecheck
text: "ST1005:"
- linters:
- gochecknoinits
# we actually want to use this init
path: private/usage/usage.go
- linters:
- staticcheck
# We deprecated all the definitions in plugin.proto but we still implement them.
text: "buf/alpha/registry/v1alpha1/plugin.proto is marked as deprecated"
- linters:
- staticcheck
# We deprecated all the definitions in generate.proto but we still implement them.
text: "buf/alpha/registry/v1alpha1/generate.proto is marked as deprecated"
- linters:
- staticcheck
# We need to handle this field in descriptor.proto.
text: "GetDeprecatedLegacyJsonFieldConflicts is deprecated"
- linters:
- forcetypeassert
# This greatly simplifies creation of descriptors, and it's safe enough since
# it's just test code.
path: private/bufpkg/bufimage/source_retention_options_test\.go
- linters:
- paralleltest
path: private/buf/cmd/buf/buf_test.go
# The LsModules tests call chdir and cannot be parallelized.
text: "LsModules"