-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy path.golangci.yml
More file actions
236 lines (233 loc) · 7.83 KB
/
.golangci.yml
File metadata and controls
236 lines (233 loc) · 7.83 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:
timeout: 10m
allow-parallel-runners: true
linters:
default: none
enable:
- asasalint
- asciicheck
- bidichk
- bodyclose
- canonicalheader
- contextcheck
- copyloopvar
- decorder
- depguard
- dupword
- embeddedstructfieldcheck
- errcheck
- errchkjson
- errname
- errorlint
- fatcontext
- forbidigo
- forcetypeassert
- funcorder
- gocheckcompilerdirectives
- goconst
- gocritic
- godot
- godoclint
- goheader
- goprintffuncname
- gosec
- gosmopolitan
- govet
- grouper
- iface
- importas
- intrange
- iotamixing
- kubeapilinter
- makezero
- misspell
- modernize
- musttag
- nakedret
- nestif
- nilerr
- nosprintfhostport
- prealloc
- predeclared
- reassign
- recvcheck
- staticcheck
- tagalign
- unconvert
- unparam
- unused
- wastedassign
- whitespace
disable:
# Below linters will be enabled once the issues reported by enabled linters are fixed.
- dupl
- cyclop
- gocyclo
- gocognit
- err113
- revive
- maintidx
- mnd
exclusions:
# Mode of the generated files analysis.
#
# - `strict`: sources are excluded by strictly following the Go generated file convention.
# Source files that have lines matching only the following regular expression will be excluded: `^// Code generated .* DO NOT EDIT\.$`
# This line must appear before the first non-comment, non-blank text in the file.
# https://go.dev/s/generatedcode
# - `lax`: sources are excluded if they contain lines like `autogenerated file`, `code generated`, `do not edit`, etc.
# - `disable`: disable the generated files exclusion.
#
# Default: strict
generated: lax
# Log a warning if an exclusion rule is unused.
# Default: false
warn-unused: true
# Predefined exclusion rules.
# Default: []
presets:
- comments
- std-error-handling
- common-false-positives
- legacy
# Excluding configuration per-path, per-linter, per-text and per-source.
rules:
# Exclude some linters from running on tests files.
- path: _test\.go
linters:
- gocyclo
- errcheck
- errname
- dupl
- gosec
- wrapcheck
- mnd
- forcetypeassert
# Exclude some linters from running on package created for tests.
- path: pkg/controller/commontest
linters:
- errname
# Run some linter only for test files by excluding its issues for everything else.
- path-except: _test\.go
linters:
- forbidigo
# Exclude all linters from running on auto-generated files.
- path: pkg/operators
linters:
- all
# To only run Kube API Linter on specific path
- path-except: api/v1alpha1/*
linters:
- kubeapilinter
# Exclude optionalfields pointer suggestions - we handle pointers case-by-case
- linters:
- kubeapilinter
text: "should be a pointer"
# Exclude omitzero suggestions - omitempty is conventional for K8s CRD struct fields
- linters:
- modernize
text: "Omitempty has no effect on nested struct fields"
# Exclude tagalign for Conditions field - kubeapilinter requires different order
- linters:
- tagalign
path: api/v1alpha1/meta.go
text: "tag is not aligned"
settings:
depguard:
rules:
# Name of a rule.
main:
# Defines package matching behavior. Available modes:
# - `original`: allowed if it doesn't match the deny list and either matches the allow list or the allow list is empty.
# - `strict`: allowed only if it matches the allow list and either doesn't match the deny list or the allow rule is more specific (longer) than the deny rule.
# - `lax`: allowed if it doesn't match the deny list or the allow rule is more specific (longer) than the deny rule.
# Default: "original"
list-mode: lax
# List of packages that are not allowed.
# Entries can be a variable (starting with $), a string prefix, or an exact match (if ending with $).
# Default: []
deny:
- pkg: "math/rand$"
desc: use math/rand/v2
- pkg: "github.com/sirupsen/logrus"
desc: not allowed
- pkg: "github.com/pkg/errors"
desc: Should be replaced by standard lib errors package
custom:
kubeapilinter:
path: "bin/kube-api-linter.so"
description: Kube API Linter lints Kube like APIs based on API conventions and best practices.
original-url: sigs.k8s.io/kube-api-linter
settings:
linters: {} # All linters enabled by default
lintersConfig: {} # All using default settings
formatters:
settings:
gci:
# Section configuration to compare against.
# Section names are case-insensitive and may contain parameters in ().
# The default order of sections is `standard > default > custom > blank > dot > alias > localmodule`.
# If `custom-order` is `true`, it follows the order of `sections` option.
# Default: ["standard", "default"]
sections:
- standard # Standard section: captures all standard packages.
- default # Default section: contains all imports that could not be matched to another section type.
- prefix(github.com/openshift/external-secrets-operator) # Custom section: groups all imports with the specified Prefix.
- blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled.
- dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled.
- alias # Alias section: contains all alias imports. This section is not present unless explicitly enabled.
- localmodule # Local module section: contains all local packages. This section is not present unless explicitly enabled.
# Checks that no inline comments are present.
# Default: false
no-inline-comments: true
# Checks that no prefix comments (comment lines above an import) are present.
# Default: false
no-prefix-comments: true
# Enable custom order of sections.
# If `true`, make the section order the same as the order of `sections`.
# Default: false
custom-order: true
# Drops lexical ordering for custom sections.
# Default: false
no-lex-order: true
gofmt:
# Simplify code: gofmt with `-s` option.
# Default: true
simplify: false
# Apply the rewrite rules to the source before reformatting.
# https://pkg.go.dev/cmd/gofmt
# Default: []
rewrite-rules:
- pattern: 'interface{}'
replacement: 'any'
- pattern: 'a[b:len(a)]'
replacement: 'a[b:]'
gofumpt:
# Module path which contains the source code being formatted.
# Default: ""
module-path: github.com/openshift/external-secrets-operator
# Choose whether to use the extra rules.
# Default: false
extra-rules: true
goimports:
# A list of prefixes, which, if set, checks import paths
# with the given prefixes are grouped after 3rd-party packages.
# Default: []
local-prefixes:
- github.com/openshift/external-secrets-operator
golines:
# Target maximum line length.
# Default: 100
max-len: 200
# Length of a tabulation.
# Default: 4
tab-len: 8
# Shorten single-line comments.
# Default: false
shorten-comments: true
# Default: true
reformat-tags: false
# Split chained methods on the dots as opposed to the arguments.
# Default: true
chain-split-dots: false