-
Notifications
You must be signed in to change notification settings - Fork 21
/
.golangci.yml
127 lines (118 loc) · 5.52 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
# More info on config here: https://golangci-lint.run/usage/configuration/
run:
deadline: 5m
issues-exit-code: 1
issues:
exclude:
# ChanMutex contains only a channel, which *is* safe to copy
- 'copylocks: .* copies lock value.*: github\.com/neondatabase/autoscaling/pkg/util\.ChanMutex'
output:
formats:
- format: "colored-line-number"
print-issued-lines: true
print-linter-name: true
sort-results: true
linters:
enable:
# enabled by default:
- errcheck # unchecked error values
- gosimple # simplifications
- govet # various items, see: https://pkg.go.dev/cmd/vet
- ineffassign # detects unused assignments
- staticcheck # some rules from staticcheck.io
- typecheck # typechecks code, like the compiler
- unused # checks for unused constants/variables/functions/types
# explicitly enabled:
- asciicheck # all identifiers are ASCII
- bidichk # no Unicode bidi sequences as per CVE-2021-42574
- bodyclose # HTTP response bodies are closed
- copyloopvar # detects places where loop variables are copied
- dupword # things like 'the the' in comments/strings
- durationcheck # bad time.Duration arithmetic
- errorlint # common errors with Go 1.13+ error wrapping
- exhaustruct # all struct fields are initialized
- gci # deterministic import ordering
- gocritic # lots of small checks, see <https://go-critic.com/overview>
- noctx # HTTP requests are passed a Context
- nolintlint # bad "nolint" directives
- predeclared # no identifiers in Go's list of predeclared identifiers, see <https://go.dev/ref/spec#Predeclared_identifiers>
- unparam # no unused function parameters or return values
linters-settings:
# see: <https://golangci-lint.run/usage/linters/#dupword>, <https://github.com/Abirdcfly/dupword>
dupword:
# only enable a few common cases here. Typically, duplicated words will be short
keywords: ["a", "and", "at", "for", "from", "the"]
# see: <https://golangci-lint.run/usage/linters/#exhaustruct>
exhaustruct:
exclude:
- '^crypto/tls\.Config$'
- '^net/http\.(Client|Server)'
- '^net\.(Dialer|TCPAddr)$'
- '^archive/tar\.Header$'
- '^k8s\.io/api/core/v1\.\w+$'
- '^k8s\.io/apimachinery/pkg/api/resource\.Quantity$'
# metav1.{CreateOptions,GetOptions,ListOptions,WatchOptions,PatchOptions,UpdateOptions,DeleteOptions}
- '^k8s\.io/apimachinery/pkg/apis/meta/v1\.(Create|Get|List|Watch|Patch|Update|Delete)Options$'
- '^k8s\.io/apimachinery/pkg/apis/meta/v1\.(Condition|LabelSelector|ObjectMeta)$'
- '^k8s\.io/client-go/tools/leaderelection/resourcelock\.ResourceLockConfig$'
- '^k8s\.io/client-go/tools/leaderelection\.(LeaderCallbacks|LeaderElectionConfig)$'
- '^sigs\.k8s\.io/controller-runtime/pkg/client\.Options$'
- '^sigs\.k8s\.io/controller-runtime/pkg/controller\.Options$'
- '^sigs\.k8s\.io/controller-runtime/pkg/envtest\.(Environment|WebhookInstallOptions)$'
- '^sigs\.k8s\.io/controller-runtime/pkg/manager\.Options$'
- '^sigs\.k8s\.io/controller-runtime/pkg/metrics/server\.Options'
- '^sigs\.k8s\.io/controller-runtime/pkg/reconcile\.Result$'
- '^sigs\.k8s\.io/controller-runtime/pkg/scheme\.Builder$'
- '^sigs\.k8s\.io/controller-runtime/pkg/webhook\.Options'
- '^github\.com/containerd/cgroups/v3/cgroup2\.(CPU|Resources)'
- '^github\.com/docker/docker/api/types/container\.Config$'
- '^github\.com/docker/docker/api/types\.\w+Options$'
- '^github\.com/opencontainers/runtime-spec/specs-go\.\w+$' # Exempt the entire package. Too many big structs.
- '^github\.com/prometheus/client_golang/prometheus(/.*)?\.\w+Opts$'
- '^github\.com/tychoish/fun/pubsub\.BrokerOptions$'
- '^github\.com/vishvananda/netlink\.\w+$' # Exempt the entire package. Too many big structs.
# vmapi.{VirtualMachine,VirtualMachineSpec,VirtualMachineMigration,VirtualMachineMigrationSpec}
- '^github\.com/neondatabase/autoscaling/neonvm/apis/neonvm/v1\.VirtualMachine(Migration)?(Spec)?$'
- '^github\.com/neondatabase/autoscaling/neonvm/apis/neonvm/v1\.IPPool$'
- '^github\.com/neondatabase/autoscaling/pkg/agent/core\.ActionSet$'
- '^github\.com/neondatabase/autoscaling/pkg/util/patch\.Operation$'
- '^github\.com/neondatabase/autoscaling/pkg/util/watch\.HandlerFuncs$'
# see: <https://golangci-lint.run/usage/linters/#gci>
gci:
custom-order: true
skip-generated: true
sections:
- standard
- default
# k8s.io can be a large group; we want that visually distinguished
- Prefix(k8s.io)
- Prefix(github.com/neondatabase/autoscaling)
# see: <https://golangci-lint.run/usage/linters/#gocritic>, <https://go-critic.com/overview>
#
# We do not use any experimental checks.
gocritic:
enabled-tags:
- diagnostic
disabled-tags:
- style
- performance
# some hand-picked checks from #style
enabled-checks:
- commentedOutImport
# see: <https://golangci-lint.run/usage/linters/#govet>
govet:
# when check-shadowing is enabled, it prevents code like
#
# foo, err := getFoo()
# ...
# for {
# bar, err := getBar()
# // ^^^ err shadows from outside the loop
# ...
# }
check-shadowing: false
# see: <https://golangci-lint.run/usage/linters/#nolintlint>
nolintlint:
allow-unused: false
require-explanation: true
require-specific: true