forked from CrunchyData/postgres-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.golangci.yaml
More file actions
211 lines (191 loc) · 5.62 KB
/
.golangci.yaml
File metadata and controls
211 lines (191 loc) · 5.62 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
# https://golangci-lint.run/usage/configuration
version: "2"
# https://golangci-lint.run/usage/linters
linters:
default: standard
enable:
- asasalint
- asciicheck
- bidichk
- bodyclose
- copyloopvar
- depguard
- dupword
- durationcheck
- errchkjson
- errname
- errorlint
- exhaustive
- exptostd
- fatcontext
- forbidigo
- ginkgolinter
- gocheckcompilerdirectives
- gochecksumtype
- goheader
- gomoddirectives
- gomodguard
- goprintffuncname
- gosec
- gosmopolitan
- grouper
- iface
- importas
- interfacebloat
- intrange
- loggercheck
- makezero
- mirror
- misspell
- musttag
- nilerr
- nilnesserr
- noctx
- nolintlint
- nosprintfhostport
- prealloc
- promlinter
- protogetter
- reassign
- recvcheck
- rowserrcheck
- sloglint
- spancheck
- sqlclosecheck
- tagalign
- testifylint
- unconvert
- unparam
- usestdlibvars
- usetesting
- wastedassign
- zerologlint
settings:
dupword:
ignore:
# We might see duplicate instances of 'fi' if we end two bash 'if' statements
- fi
depguard:
rules:
everything:
files: ['$all']
list-mode: lax
allow:
- go.opentelemetry.io/otel/semconv/v1.27.0
deny:
- pkg: go.opentelemetry.io/otel/semconv
desc: Use "go.opentelemetry.io/otel/semconv/v1.27.0" instead.
- pkg: io/ioutil
desc: Use the "io" and "os" packages instead. See https://go.dev/doc/go1.16#ioutil
- pkg: math/rand$
desc: Use the "math/rand/v2" package instead. See https://go.dev/doc/go1.22#math_rand_v2
not-tests:
files: ['!$test','!**/internal/testing/**']
list-mode: lax
deny:
- pkg: net/http/httptest
desc: Should be used only in tests.
- pkg: testing/*
desc: The "testing" packages should be used only in tests.
- pkg: github.com/crunchydata/postgres-operator/internal/crd/*
desc: The "internal/crd" packages should be used only in tests.
- pkg: github.com/crunchydata/postgres-operator/internal/testing/*
desc: The "internal/testing" packages should be used only in tests.
- pkg: k8s.io/client-go/discovery
desc: Use the "internal/kubernetes" package instead.
tests:
files: ['$test']
list-mode: lax
deny:
- pkg: github.com/pkg/errors
desc: Use the "errors" package unless you are interacting with stack traces.
errchkjson:
check-error-free-encoding: true
goheader:
template: |-
Copyright {{ DATES }} Crunchy Data Solutions, Inc.
SPDX-License-Identifier: Apache-2.0
values:
regexp:
DATES: ((201[7-9]|202[0-5]) - 2026|2026)
gomodguard:
blocked:
modules:
- go.yaml.in/yaml/v2: { recommendations: [sigs.k8s.io/yaml] }
- go.yaml.in/yaml/v3: { recommendations: [sigs.k8s.io/yaml] }
- gopkg.in/yaml.v2: { recommendations: [sigs.k8s.io/yaml] }
- gopkg.in/yaml.v3: { recommendations: [sigs.k8s.io/yaml] }
- gotest.tools: { recommendations: [gotest.tools/v3] }
- k8s.io/kubernetes:
reason: k8s.io/kubernetes is for building kubelet, kubeadm, etc.
importas:
no-unaliased: true
alias:
- pkg: k8s.io/api/(\w+)/(v[\w\w]+)
alias: $1$2
- pkg: k8s.io/apimachinery/pkg/apis/(\w+)/(v[\w\d]+)
alias: $1$2
- pkg: k8s.io/apimachinery/pkg/api/errors
alias: apierrors
spancheck:
checks: [end, record-error]
extra-start-span-signatures:
- github.com/crunchydata/postgres-operator/internal/tracing.Start:opentelemetry
ignore-check-signatures:
- tracing.Escape
exclusions:
warn-unused: true
presets:
- common-false-positives
- legacy
- std-error-handling
rules:
# It is fine for tests to use "math/rand" packages.
- linters: [gosec]
path: '(.+)_test[.]go'
text: weak random number generator
# This internal package is the one place we want to do API discovery.
- linters: [depguard]
path: internal/kubernetes/discovery.go
text: k8s.io/client-go/discovery
# Postgres HBA rules often include "all all all"
- linters: [dupword]
path: /(hba|postgres)[^/]+$
text: words \(all\) found
# These value types have unmarshal methods.
# https://github.com/raeperd/recvcheck/issues/7
- linters: [recvcheck]
path: internal/pki/pki.go
text: methods of "(Certificate|PrivateKey)"
- linters: [staticcheck]
text: corev1.(Endpoints|EndpointSubset) is deprecated
- linters: [staticcheck]
path: internal/controller/
text: >-
deprecated: Use `RequeueAfter` instead
- linters: [staticcheck]
path: internal/controller/runtime
text: >-
client.Apply is deprecated
- linters: [staticcheck]
path: internal/controller/(postgrescluster|pgupgrade|standalone_pgadmin)
text: >-
GetEventRecorderFor is deprecated
# https://golangci-lint.run/usage/formatters
formatters:
enable:
- gci
- gofmt
settings:
gci:
sections:
- standard
- default
- localmodule
issues:
# Fix only when requested
fix: false
# Show all issues at once
max-issues-per-linter: 0
max-same-issues: 0
uniq-by-line: false