-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy path.golangci.yml
More file actions
307 lines (304 loc) · 11.6 KB
/
Copy path.golangci.yml
File metadata and controls
307 lines (304 loc) · 11.6 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
version: "2"
run:
go: "1.27"
issues-exit-code: 1
tests: true
output:
formats:
text:
path: stdout
print-linter-name: true
print-issued-lines: true
linters:
enable:
- asasalint
- asciicheck
- bidichk
- bodyclose
- contextcheck
- depguard
- dupl
- durationcheck
- errchkjson
- errorlint
- exhaustive
- fatcontext
- forbidigo
- gocheckcompilerdirectives
- gochecksumtype
- goconst
- gocritic
- gosmopolitan
- lll
- loggercheck
- makezero
- misspell
- mnd
- musttag
- nilerr
- nilnesserr
- noctx
- paralleltest
- perfsprint
- prealloc
- protogetter
- reassign
- rowserrcheck
- spancheck
- sqlclosecheck
- staticcheck
- testableexamples
- testifylint
- testpackage
- thelper
- tparallel
- unconvert
- unparam
- usetesting
- wastedassign
- wsl_v5
- zerologlint
settings:
depguard:
rules:
no-direct-go-getter:
# Direct hashicorp/go-getter imports are confined to the internal/getter
# package (which owns the integration) plus two carve-out files that
# would otherwise create import cycles. Everything else must go through
# internal/getter.
list-mode: lax
files:
- $all
- "!**/internal/getter/**"
- "!**/internal/util/file.go"
- "!**/internal/cas/stacks.go"
deny:
- pkg: github.com/hashicorp/go-getter
desc: use github.com/gruntwork-io/terragrunt/internal/getter instead
- pkg: github.com/hashicorp/go-getter/v2
desc: use github.com/gruntwork-io/terragrunt/internal/getter instead
- pkg: github.com/hashicorp/go-getter/v2/helper/url
desc: use github.com/gruntwork-io/terragrunt/internal/getter URLParse instead
- pkg: github.com/hashicorp/go-getter/s3/v2
desc: use github.com/gruntwork-io/terragrunt/internal/getter instead
- pkg: github.com/hashicorp/go-getter/gcs/v2
desc: use github.com/gruntwork-io/terragrunt/internal/getter instead
no-direct-markdown:
# Markdown parsing and rendering is confined to the internal/md
# package, which owns the libraries doing it. Everything else, tests
# included, reads and renders Markdown through internal/md, so what a
# document can be asked is chosen there and a library can be replaced
# without touching a caller.
list-mode: lax
files:
- $all
- "!**/internal/md/**"
deny:
- pkg: charm.land/glamour/v2
desc: use github.com/gruntwork-io/terragrunt/internal/md instead
- pkg: github.com/yuin/goldmark
desc: use github.com/gruntwork-io/terragrunt/internal/md instead
dupl:
threshold: 120
# Terragrunt routes every side effect through the virtualized environment
# (internal/venv) so a run can be driven entirely in memory. These patterns
# catch the ways code reaches past that seam to the real OS. The exclusion
# list at the bottom of this file allows for exclusions (typically in tests).
forbidigo:
analyze-types: true
forbid:
- pattern: ^os\.(ReadFile|WriteFile|Open|OpenFile|OpenRoot|Create|CreateTemp|MkdirTemp|Stat|Lstat|Mkdir|MkdirAll|Remove|RemoveAll|ReadDir|Rename|Symlink|Readlink|Chmod|Chdir|Getwd|Link|Truncate)$
pkg: ^os$
msg: read and write through the venv's vfs.FS instead of the real filesystem
- pattern: ^os\.(Getenv|Setenv|Unsetenv|LookupEnv|Environ|ExpandEnv)$
pkg: ^os$
msg: read and write the venv's Env map instead of the process environment
- pattern: ^os\.(UserHomeDir|UserCacheDir|UserConfigDir)$
pkg: ^os$
msg: use the venv's Platform handles instead of reading the invoking user's directories
- pattern: ^os\.(Getpid|Executable|Hostname)$
pkg: ^os$
msg: use the venv's Platform handles instead of reading the running process
- pattern: ^os\.Args$
pkg: ^os$
msg: take the arguments the CLI was handed rather than reading the process arguments
- pattern: ^runtime\.(GOOS|GOARCH)$
pkg: ^runtime$
msg: take the platform from the venv's Platform.GOOS and Platform.GOARCH instead of the compiled-in constants
- pattern: ^os\.(Stdin|Stdout|Stderr)$
pkg: ^os$
msg: read and write the venv's Reader and Writers, and ask its Terminal whether a stream is a tty
- pattern: ^exec\.(Command|CommandContext|LookPath)$
pkg: ^os/exec$
msg: spawn through the venv's vexec.Exec instead of os/exec
- pattern: ^http\.(Get|Post|Head|PostForm)$
pkg: ^net/http$
msg: send through the venv's vhttp.Client instead of net/http package functions
- pattern: ^http\.Default(Client|Transport)$
pkg: ^net/http$
msg: send through the venv's vhttp.Client instead of the shared default client
- pattern: ^http\.Client$
pkg: ^net/http$
msg: take the client from the venv's vhttp.Client rather than building one
- pattern: ^net\.(Listen|ListenPacket|ListenConfig)$
pkg: ^net$
msg: open sockets through the venv's Listen handle instead of binding directly
- pattern: ^filepath\.(Walk|WalkDir|Glob)$
pkg: ^path/filepath$
msg: walk the venv's vfs.FS via vfs.WalkDir or vfs.WalkDirParallel instead of the real filesystem
- pattern: ^filepath\.EvalSymlinks$
pkg: ^path/filepath$
msg: resolve links on the venv's vfs.FS via vfs.EvalSymlinks, or vfs.ResolveForCompare when the result is to be compared against another path
- pattern: ^(vfs\.NewOSFS|vexec\.NewOSExec|vhttp\.NewOSClient|vsops\.NewOSDecrypter)$
msg: take the handle from the venv already in scope rather than building a fresh OS-backed one
- pattern: ^config\.LoadDefaultConfig$
pkg: ^github.com/aws/aws-sdk-go-v2/config$
msg: build AWS config via awshelper.NewAWSConfigBuilder so requests ride the venv's HTTP client
- pattern: ^storage\.NewClient$
pkg: ^cloud.google.com/go/storage$
msg: build the GCS client via gcphelper.NewGCPConfigBuilder so requests ride the venv's HTTP client
errcheck:
check-type-assertions: false
check-blank: false
exclude-functions:
- (*os.File).Close
errorlint:
errorf: true
asserts: true
comparison: true
goconst:
# v2.12+ counts package-wide test fixtures; keep repeated test data local.
# Tracked upstream: https://github.com/golangci/golangci-lint/issues/6563
ignore-tests: true
# v2.13+ reports repeated schema/config map keys, which are data rather than constants.
# Tracked upstream: https://github.com/golangci/golangci-lint/issues/6707
ignore-map-keys: true
min-len: 3
min-occurrences: 5
gocritic:
enabled-tags:
- performance
disabled-tags:
- experimental
govet:
enable:
- fieldalignment
- printf
- unusedwrite
nakedret:
max-func-lines: 20
staticcheck:
checks:
- all
- -SA9005
- -QF1008
- -ST1001
unparam:
check-exported: false
wsl_v5:
allow-whole-block: false
branch-max-lines: 2
exclusions:
generated: lax
rules:
- linters:
- dupl
- errcheck
- gocyclo
- mnd
- unparam
- wsl
path: _test\.go
# Tests frequently drive real fixtures on disk, so tests
# are allowed to bypass venv.
- linters:
- forbidigo
path: (_test\.go|^test/|^internal/git/server\.go)
# The packages that implement venv, plus the pty layer they sit on, are
# where the real OS calls are supposed to live. internal/os/signal and
# internal/os/stdout are deliberately outside this list: neither reaches
# the real OS any more, so neither should be able to start.
- linters:
- forbidigo
path: ^internal/(vfs|vexec|vhttp|vsops|venv)/|^internal/os/exec/
# A pty is the real terminal by definition, so the two callers that
# decide whether to allocate one read the real descriptor to do it.
# Both are reached only once the venv's Terminal has already reported
# that the stream is a tty.
- linters:
- forbidigo
path: ^(internal/view/tui/tty\.go|internal/tf/run_cmd\.go)$
# main is where the process arguments enter the program and become the
# arguments every layer below is handed, so it is the one place that has
# nothing to read them from.
- linters:
- forbidigo
text: use of `os.Args`
path: ^main\.go$
# The vendored urfave/cli help renderer reads CLI_TEMPLATE_ERROR_DEBUG
# from the process with os.Getenv, so the only way to turn its template
# diagnostics on is to put the variable where it will look.
- linters:
- forbidigo
text: use of `os.Setenv`
path: ^internal/cli/commands/help/cli\.go$
# Pre-existing style debt in two paths, held back so it can be cleaned
# up on its own. The venv rules are deliberately absent from this list,
# so they still apply to both paths.
- linters:
- errcheck
- govet
- mnd
- paralleltest
- perfsprint
- staticcheck
- testifylint
- thelper
- tparallel
- unused
- wsl_v5
path: ^(internal/github/|test/integration_docs_test\.go$)
# We end up with duplicated content in this package to save us from duplicating code in other packages.
- linters:
- dupl
path: cli/flags/shared
# BubbleTea's tea.Model expects value-receiver methods (Init/Update/View),
# so Model and WelcomeModel in the TUI packages trip gocritic's hugeParam
# check. Silence it for these packages only; hugeParam still runs everywhere else.
- linters:
- gocritic
text: "hugeParam:"
path: (internal/cli/commands/(browse|catalog)/tui/|internal/view/tui/)
# Incrementally linting lines that are too long to ensure that
# we don't have conflicts on every file in the codebase while
# trying to get this merged in.
- linters:
- lll
path-except: "^(internal/awshelper/|internal/cas/|internal/cli/commands/(backend/(delete|migrate)|browse|catalog/tui/command|dag/graph|exec|find|help|list|scaffold|stack)/|internal/cloner/|internal/codegen/|internal/configbridge/|internal/discovery/|internal/engine/|internal/errorconfig/|internal/errors/|internal/experiment/|internal/filter/|internal/gcphelper/|internal/getter/|internal/git/|internal/os/exec/|internal/prepare/|internal/queue/|internal/report/|internal/retry/|internal/runner/(common|graph|run/creds|runall|runcfg)/|internal/stacks/(generate|output)/|internal/telemetry/|internal/tf/cache/(controllers|middleware)/|internal/tflint/|internal/tips/|internal/vfs/|internal/worktrees/|pkg/log/(format/(options|placeholders)|writer)/|pkg/options/)"
paths:
- ^docs/
- ^_ci/
- ^\.github/
- ^\.circleci/
- third_party$
- builtin$
- examples$
issues:
max-issues-per-linter: 0
max-same-issues: 0
formatters:
enable:
- goimports
settings:
gofmt:
simplify: true
exclusions:
generated: lax
paths:
- ^docs/
- ^_ci/
- ^\.github/
- ^\.circleci/
- third_party$
- builtin$
- examples$