This repository has been archived by the owner on Oct 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.golangci.yaml
233 lines (199 loc) · 6.5 KB
/
.golangci.yaml
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
run:
timeout: 10m
linters:
enable-all: false
enable:
- megacheck
- govet
- cyclop
- dupl
- errcheck
- errorlint
- exhaustive
- funlen
- gci
- gocognit
- nestif
- goconst
- gocritic
- gocyclo
- gofmt
- gofumpt
- goimports
- gomnd
- gomoddirectives
- gosec
- gosimple
- govet
- ifshort
- ineffassign
- durationcheck
- errname
- lll
- misspell
- nolintlint
- revive
- staticcheck
- stylecheck
- unparam
- unused
- whitespace
- asciicheck
- bodyclose
- dogsled
- exportloopref
- forcetypeassert
- godot
- goerr113
- goprintffuncname
- importas
- nakedret
- nilerr
- noctx
- prealloc
- predeclared
- rowserrcheck
- unconvert
- wastedassign
disable:
- wrapcheck # Reason: 'ignore package' option is not working. Enable when will be fixed.
- wsl # Adds mandatory empty lines around code blocks. Reason: it's a matter of taste.
- depguard # Go linter that checks if package imports are in a list of acceptable packages. Reason: no use-case.
- exhaustivestruct # Checks if all struct's fields are initialized. Reason: use struct default values.
- forbidigo # Forbids identifiers. Reason: no use-case.
- gochecknoglobals # Check that no global variables exist. Reason: no use-case.
- godox # Tool for detection of FIXME, TODO. Reason: todo's are cool.
- gochecknoinits # Checks that no init functions are present in Go code. Reason: operator-sdk have inits.
- goheader # Checks is file header matches to pattern. Reason: no use-case.
- golint # Reason: deprecated, revive used instead.
- gomodguard # Allow and block list linter for direct Go module dependencies. Reason: no use-case.
- makezero # Finds slice declarations with non-zero initial length. Reason: allocate slices of known init size; conflicts with 'prealloc' linter.
- maligned # Tool to detect Go structs that would take less memory if their fields were sorted.Reason: premature.
- interfacer # Reason: deprecated.
- nlreturn # Checks for a new line before return and branch statements to increase code clarity. Reason: it's a matter of taste.
- promlinter # Check Prometheus metrics naming via promlint. Reason: no use-case.
- scopelint # Reason: deprecated.
- paralleltest # Reason: lets don't lint tests for now.
linters-settings:
cyclop:
max-complexity: 20
skip-tests: true
dupl:
threshold: 150
errcheck:
# report about not checking of errors in type assertions: `a := b.(MyStruct)`;
# default is false: such cases aren't reported by default.
check-type-assertions: true
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
# default is false: such cases aren't reported by default.
check-blank: true
errorlint:
# Check whether fmt.Errorf uses the %w verb for formatting errors.
errorf: true
# Check for plain type assertions and type switches
asserts: true
# Check for plain error comparisons
comparison: true
exhaustive:
# Indicates that switch statements are to be considered exhaustive if a
# 'default' case is present, even if all enum members aren't listed in the switch.
default-signifies-exhaustive: true
funlen:
lines: 100
statements: 50
goconst:
# Search also for duplicated numbers, false by default.
numbers: true
gocritic:
disabled-checks:
- rangeValCopy # Reason: premature optimisation - saves memory but hurts readability.
- unnamedResult # Reason: named return params may be less readable but it is discussible.
enabled-tags:
- diagnostic
- style
- performance
- experimental
- opinionated
gocyclo:
# Minimal code complexity to report, 30 by default (but we recommend 10-20).
min-complexity: 20
gofumpt:
extra-rules: true
gomnd:
settings:
mnd:
ignored-numbers: [10,1,2,3,4,5]
gosimple:
checks: [ "all" ]
govet:
check-shadowing: true
enable-all: true
ifshort:
# Maximum length of variable declaration measured in number of lines, after which linter won't suggest using short syntax.
# Has higher priority than max-decl-chars.
max-decl-lines: 1
# Maximum length of variable declaration measured in number of characters, after which linter won't suggest using short syntax.
max-decl-chars: 30
lll:
line-length: 165
misspell:
locale: US
staticcheck:
checks: [ "all" ]
stylecheck:
checks: ["all", "-ST1000", "-ST1003", "-ST1016", "-ST1020", "-ST1021", "-ST1022"]
whitespace:
multi-if: false # Enforces newlines (or comments) after every multi-line if statement. Reason: it's a matter of taste.
multi-func: false # Enforces newlines (or comments) after every multi-line function signature. Reason: it's a matter of taste.
wrapcheck:
ignorePackageGlobs:
- sigs.k8s.io/controller-runtime/pkg/*
- github.com/pkg/*
issues:
exclude-rules:
# Exclude some linters from running on tests files.
- path: _test\.go
linters:
- funlen
- gocyclo
- errcheck
- dupl
- gosec
- ineffassign
- forcetypeassert
- goconst
# operator init is generated by operator-sdk in main func and it is quite long.
- path: main\.go
linters:
- funlen
# autogenerated client.
- path: clientset/
linters:
- gocritic
- lll
- dupl
# Exclude mandatory comment on Exported functions. Reason: forces writing comments only to make linter happy.
- linters:
- revive
text: "exported:"
# Exclude mandatory comment on packages
- linters:
- revive
text: "package-comments:"
# Exclude structure fields alignment check. Reason: premature optimization.
- linters:
- govet
text: "fieldalignment:"
# Exclude lll issues for long lines with +kubebuilder. Reason: can't break codegen annotations.
- linters:
- lll
source: "^//\\+kubebuilder"
# To list all excluded by default patterns execute `golangci-lint run --help`.
# Default value for this option is true.
exclude-use-default: false
# 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
# Fix found issues (if it's supported by the linter)
fix: true