-
Notifications
You must be signed in to change notification settings - Fork 758
Expand file tree
/
Copy path.golangci.yml
More file actions
236 lines (236 loc) · 6.92 KB
/
.golangci.yml
File metadata and controls
236 lines (236 loc) · 6.92 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
version: "2"
run:
issues-exit-code: 1
tests: true
linters:
default: none
enable:
- asasalint
- bodyclose
- copyloopvar
- depguard
- errcheck
- errorlint
- forbidigo
- gocritic
- godot
- gosec
- govet
- ineffassign
- intrange
- modernize
- misspell
- noctx
- nolintlint
- perfsprint
- revive
- staticcheck
- testifylint
- unconvert
- unparam
- unused
- usestdlibvars
- usetesting
settings:
depguard:
rules:
no-sdk-instrumentation:
files:
- '**/*/{bridges,instrumentation}/**/*.go'
- '!$test'
- "!**/*/bridges/prometheus/*.go" # prometheus bridge is meant to use the SDK
- "!**/*/instrumentation/runtime/*.go" # runtime instrumentation is meant to use the SDK
- '!**/*test/*.go'
- '!**/*test/**/*.go'
- '!**/*example/*.go'
- '!**/*example/**/*.go'
deny:
- pkg: go.opentelemetry.io/otel/sdk
desc: Bridges and instrumentations should not use the SDKs, except in test or example modules
non-tests:
files:
- '!$test'
- '!**/*test/*.go'
deny:
- pkg: testing
- pkg: github.com/stretchr/testify
- pkg: crypto/md5
- pkg: crypto/sha1
- pkg: crypto/**/pkix
semconv:
list-mode: lax
deny:
- pkg: go.opentelemetry.io/otel/semconv
desc: Use go.opentelemetry.io/otel/semconv/v1.40.0 instead. If a newer semconv version has been released, update the depguard rule.
allow:
- go.opentelemetry.io/otel/semconv/v1.21.0 # still used by otelmongo
- go.opentelemetry.io/otel/semconv/v1.40.0
forbidigo:
forbid:
- pattern: '^trace\.Span\.RecordError$'
pkg: '^go\.opentelemetry\.io/otel/trace$'
msg: "Span.RecordError is not allowed, Reference: https://github.com/open-telemetry/opentelemetry-go-contrib/pull/8386"
exclude-godoc-examples: false
analyze-types: true
gocritic:
disabled-checks:
- appendAssign
- exitAfterDefer
- exposedSyncMutex
- hugeParam
- unnamedResult
enable-all: true
godot:
exclude:
# Exclude sentence fragments for lists.
- ^[ ]*[-•]
# Exclude sentences prefixing a list.
- :$
misspell:
locale: US
ignore-rules:
- cancelled
nolintlint:
require-explanation: true
require-specific: true
perfsprint:
int-conversion: true
err-error: true
errorf: true
sprintf1: true
strconcat: true
revive:
# Sets the default failure confidence.
# This means that linting errors with less than 0.8 confidence will be ignored.
# Default: 0.8
confidence: 0.01
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md
rules:
- name: blank-imports
- name: bool-literal-in-expr
- name: constant-logical-expr
# TODO (#2877) re-enable linter when it is compatible. https://github.com/golangci/golangci-lint/issues/3280
- name: context-as-argument
disabled: true
arguments:
- allow-types-before: "*testing.T"
- name: context-keys-type
- name: deep-exit
- name: defer
arguments:
- ["call-chain", "loop"]
- name: dot-imports
- name: duplicated-imports
- name: early-return
- name: empty-block
- name: empty-lines
- name: error-naming
- name: error-return
- name: error-strings
- name: errorf
- name: exported
arguments:
- "say-repetitive-instead-of-stutters"
- name: flag-parameter
- name: identical-branches
- name: if-return
- name: increment-decrement
- name: indent-error-flow
- name: import-shadowing
- name: package-comments
- name: range
- name: range-val-in-closure
- name: range-val-address
- name: redefines-builtin-id
- name: string-format
arguments:
- - panic
- '/^[^\n]*$/'
- must not contain line breaks
- name: struct-tag
- name: superfluous-else
- name: time-equal
- name: unconditional-recursion
- name: unexported-return
- name: unused-parameter
- name: unused-receiver
- name: unhandled-error
arguments:
- "fmt.Fprint"
- "fmt.Fprintf"
- "fmt.Fprintln"
- "fmt.Print"
- "fmt.Printf"
- "fmt.Println"
- name: unnecessary-stmt
- name: use-any
- name: useless-break
- name: var-declaration
- name: var-naming
arguments:
- ["ID"] # AllowList
- ["Otel", "Aws", "Gcp"] # DenyList
- - skip-initialism-name-checks: true
upper-case-const: true
skip-package-name-checks: true
skip-package-name-collision-with-go-std: true
- name: waitgroup-by-value
testifylint:
enable-all: true
disable:
- float-compare
- require-error
usetesting:
context-background: true
context-todo: true
exclusions:
generated: lax
presets:
- common-false-positives
- legacy
- std-error-handling
rules:
# TODO: Having appropriate comments for exported objects helps development,
# even for objects in internal packages. Appropriate comments for all
# exported objects should be added and this exclusion removed.
- linters:
- revive
path: .*internal/.*
text: exported (method|function|type|const) (.+) should have comment or be unexported
# Yes, they are, but it's okay in a test.
- linters:
- revive
path: _test\.go
text: exported func.*returns unexported type.*which can be annoying to use
# Example test functions should be treated like main.
- linters:
- revive
path: example.*_test\.go
text: calls to (.+) only in main[(][)] or init[(][)] functions
# It's okay to not run gosec and perfsprint in a test.
- linters:
- gosec
- perfsprint
- usestdlibvars
path: _test\.go
# Ignoring gosec G402: TLS MinVersion too low
# as the https://pkg.go.dev/crypto/tls#Config handles MinVersion default well.
- linters:
- gosec
path: config/*.go
text: 'G402: TLS MinVersion too low.'
issues:
max-issues-per-linter: 0
max-same-issues: 0
formatters:
enable:
- gofumpt
- goimports
settings:
gofumpt:
extra-rules: true
goimports:
local-prefixes:
- go.opentelemetry.io/contrib
exclusions:
generated: lax