-
Notifications
You must be signed in to change notification settings - Fork 127
Expand file tree
/
Copy path.golangci.yml
More file actions
200 lines (168 loc) · 5.98 KB
/
Copy path.golangci.yml
File metadata and controls
200 lines (168 loc) · 5.98 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
# yaml-language-server: $schema=https://golangci-lint.run/jsonschema/golangci.jsonschema.json
version: "2"
run:
timeout: 10m
concurrency: 2
tests: false
# Pin the Go version used by type-checking and analyzers
go: "1.23"
formatters:
# Code formatters moved out of linters in v2
enable:
- goimports
- gofmt
settings:
goimports:
# put imports beginning with prefix after 3rd-party packages;
# it's a comma-separated list of prefixes
local-prefixes:
- github.com/kubevela/velaux
gofmt:
# simplify code: gofmt with `-s` option, true by default
simplify: true
linters:
enable:
- govet
- gocyclo
- gocritic
- goconst
- revive
- unconvert
- misspell
- nakedret
- unused
- staticcheck
- copyloopvar
- intrange
disable:
- rowserrcheck
- sqlclosecheck
- errchkjson
- contextcheck
# v2 replaces `issues.*` ignores with `linters.exclusions.*`
exclusions:
# These replace issues.exclude-dirs / exclude-files
paths:
- hack
- e2e
- node_modules
- generated
# Excluding configuration per-path and per-linter
rules:
# Ignore unchecked errors from fmt.*
- path: '(.+)\.go'
linters: [errcheck]
text: 'fmt\\.'
# Ignore unchecked errors from io/ioutil functions starting with Read
- path: '(.+)\.go'
linters: [errcheck]
text: 'io/ioutil.*Read'
# Exclude some linters from running on tests files.
- path: _test(ing)?\.go
linters: [gocyclo, errcheck, dupl, gosec, unparam]
# Ease some gocritic warnings on test files.
- path: _test\.go
linters: [gocritic]
text: '(unnamedResult|exitAfterDefer)'
# Gosmopolitan complains of internationalization issues on the file that actually defines
# the translation.
- path: i18n\.go
linters: [gosmopolitan]
text: Han
# These are performance optimisations rather than style issues per se.
# They warn when function arguments or range values copy a lot of memory
# rather than using a pointer.
- linters: [gocritic]
text: '(hugeParam|rangeValCopy):'
# This "TestMain should call os.Exit to set exit code" warning is not clever
# enough to notice that we call a helper method that calls os.Exit.
- linters: [staticcheck]
text: 'SA3000:'
# This is a "potential hardcoded credentials" warning. It's triggered by
# any variable with 'secret' in the name, and thus hits many false
# positives in Kubernetes land where a Secret is an object type.
- linters: [gosec]
text: 'G101:'
# This is an 'errors unhandled' warning that duplicates errcheck.
- linters: [gosec]
text: 'G104:'
# Style nits we do not care about here
- linters: [revive]
text: "don't use an underscore"
- linters: [revive]
text: 'error-strings: error strings should not be capitalized or end with punctuation or a newline'
settings:
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: false
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
# default is false: such cases aren't reported by default.
check-blank: false
# comma-separated list of pairs of the form pkg:regex
# the regex is used to ignore names within pkg. (default "fmt:.*").
exclude-functions:
- 'fmt.*'
- 'io/ioutil:^Read.*'
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
# govet: in v2 the old check-shadowing option is removed; leaving defaults is equivalent to "false"
# If you ever want it back: enable "shadow" explicitly.
# govet:
# enable: [shadow]
revive:
# minimal confidence for issues, default is 0.8
# In v2 the key is `confidence` (not `min-confidence`)
confidence: 0.8
rules:
# Turn off the package comment rule completely
- name: package-comments
disabled: true
# Keep your previous tweak
- name: unused-parameter
disabled: true
gocyclo:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 30
dupl:
# tokens count to trigger issue, 150 by default
threshold: 100
goconst:
# minimal length of string constant, 3 by default
min-len: 3
# minimal occurrences count to trigger, 3 by default
min-occurrences: 5
lll:
# tab width in spaces. Default to 1.
tab-width: 1
# unused / unparam: v2 dropped some knobs like check-exported; defaults are fine
nakedret:
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
max-func-lines: 30
gocritic:
# Enable multiple checks by tags
enabled-tags:
- performance
settings:
captLocal:
paramsOnly: true
rangeValCopy:
sizeThreshold: 32
makezero:
# Allow only slices initialized with a length of zero. Default is false.
always: false
issues:
# Show only new issues: if there are unstaged changes or untracked files,
# only those changes are analyzed, else only changes in HEAD~ are analyzed.
# It's a super-useful option for integration of golangci-lint into existing
# large codebase. It's not practical to fix all existing issues at the moment
# of integration: much better don't allow issues in new code.
# Default is false.
new: 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