-
Notifications
You must be signed in to change notification settings - Fork 570
Expand file tree
/
Copy path.golangci.yml
More file actions
170 lines (166 loc) · 5.31 KB
/
.golangci.yml
File metadata and controls
170 lines (166 loc) · 5.31 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
version: "2"
run:
timeout: 10m
linters:
default: none
enable:
- asasalint
- asciicheck
- bidichk
- copyloopvar
- decorder
- dupl
- durationcheck
- errcheck
- errname
- errorlint
- exhaustive
- ginkgolinter
- gocheckcompilerdirectives
- govet
- grouper
- importas
- ineffassign
- makezero
- misspell
- nakedret
- nilnil
- promlinter
- revive
- sloglint
- staticcheck
- unconvert
- unused
- usestdlibvars
- whitespace
- defercleanupcluster
- defercleanupctx
- ginkgoreturnctx
- describefunc
settings:
dupl:
threshold: 400
exhaustive:
check:
- switch
- map
ignore-enum-types: ResourceName|Atom
default-signifies-exhaustive: true
importas:
no-unaliased: true
alias:
# Kubernetes
- pkg: k8s\.io/api/(\w+)/(v[\w\d]+)
alias: $1$2
- pkg: k8s\.io/apimachinery/pkg/api/(\w+)/(v[\w\d]+)
alias: $1$2
- pkg: k8s.io/apimachinery/pkg/api/errors
alias: kerrors
- pkg: k8s.io/apimachinery/pkg/apis/meta/internalversion
alias: metainternalversion
revive:
rules:
- name: dot-imports
disabled: false
arguments:
- allowed-packages: [ "github.com/onsi/ginkgo/v2", "github.com/onsi/gomega" ]
tagalign:
order:
- protobuf
- json
- yaml
- xml
- form
custom:
defercleanupcluster:
type: module
description: "Checks that cluster.Create calls have a matching DeferCleanup(cluster.Destroy(...))"
original-url: github.com/loft-sh/e2e-framework/linters/defercleanupcluster
defercleanupctx:
type: module
description: "Checks that DeferCleanup is not called with a setup.Func; use e2e.DeferCleanupCtx(ctx, fn) instead"
original-url: github.com/loft-sh/e2e-framework/linters/defercleanupctx
ginkgoreturnctx:
type: module
description: "Checks that Ginkgo node functions that reassign context.Context also return it"
original-url: github.com/loft-sh/e2e-framework/linters/ginkgoreturnctx
describefunc:
type: module
description: "Checks that Ginkgo Describe calls with cluster.Use use the exported function pattern instead of auto-registration"
original-url: github.com/loft-sh/e2e-framework/linters/describefunc
staticcheck:
dot-import-whitelist:
- github.com/onsi/ginkgo/v2
- github.com/onsi/gomega
checks:
- all
# All below staticcheck exclusions have been added when migrating golangci-lint config from
# v1 to v2 and for the sake of not making source code changes when upgrading golangci-lint.
- "-QF1001" # exclude 'could apply De Morgan's law'
- "-QF1003" # exclude 'could use tagged switch on value'
- "-QF1004" # exclude 'could use strings.ReplaceAll instead'
- "-QF1008" # exclude 'could remove embedded field "<field>" from selector'
- "-QF1012" # exclude 'Use fmt.Fprintf(...) instead of WriteString(fmt.Sprintf(...))'
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
# We are still using the deprecated exportKubeConfig.Secret field in a couple of places in code (as the support for
# exportKubeConfig.secret config is still not entirely removed).
- path: config/config.go
text: 'SA1019: (.+)Secret is deprecated: Use AdditionalSecrets instead.'
- path: pkg/config/validation.go
text: 'SA1019: (.+)Secret is deprecated: Use AdditionalSecrets instead.'
# Skip ST1003 (package name with underscores) for e2e-next folder
- path: ^e2e-next/
linters: [staticcheck]
text: 'ST1003: should not use underscores in package names'
# The following exceptions apply only to existing packages that need refactoring.
# The rule remains enabled globally.
- path: ^pkg/(cli/util|server/types|snapshot/types|syncer/types|util|plugin/types)/[^/]+\.go$
linters: [revive]
text: avoid meaningless package names
- path-except: 'e2e-next/'
linters:
- defercleanupcluster
- path-except: 'e2e-next/'
linters:
- defercleanupctx
- path-except: 'e2e-next/'
linters:
- ginkgoreturnctx
- path-except: 'e2e-next/'
linters:
- describefunc
paths:
- licenses
# Paths below are added by 'golangci-lint migrate' when migrating from v1 to v2. They are the
# equivalent of v1 config 'issues.exclude-dirs-use-default: true'.
- third_party$
- builtin$
- examples$
issues:
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
max-issues-per-linter: 0
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
max-same-issues: 0
formatters:
enable:
- gofmt
- goimports
settings:
gofmt:
simplify: true
exclusions:
generated: lax
paths:
- licenses
# Paths below are added by 'golangci-lint migrate' when migrating from v1 to v2. They are the
# equivalent of v1 config 'issues.exclude-dirs-use-default: true'.
- third_party$
- builtin$
- examples$