-
Notifications
You must be signed in to change notification settings - Fork 331
/
.golangci.yaml
215 lines (165 loc) · 5.42 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
run:
timeout: 10m
allow-parallel-runners: true
exclude-dirs:
- client
- injection/clients
output:
uniq-by-line: true
sort-results: true
sort-order:
- linter
- file
show-stats: true
issues:
max-issues-per-linter: 0
max-same-issues: 0
exclude-rules:
- path: test # Excludes /test, *_test.go etc.
linters:
- gosec
- unparam
- noctx
- protogetter
- linters: ["gocritic"]
# Fixes are non-trivial do in a follow up
text: "ifElseChain"
linters-settings:
# goimports:
# local-prefixes: knative.dev/pkg
gomodguard:
blocked:
modules:
- github.com/ghodss/yaml:
recommendations:
- sigs.k8s.io/yaml
- go.uber.org/atomic:
recommendations:
- sync/atomic
- io/ioutil:
recommendations:
- os
- io
- github.com/hashicorp/go-multierror:
reason: "use errors.Join"
recommendations:
- errors
- go.uber.org/multierr:
reason: "use errors.Join"
recommendations:
- errors
revive:
rules:
# use unparam linter instead - defaults are better
- name: unused-parameter
disabled: true
linters:
disable:
- errcheck
enable:
# Check for pass []any as any in variadic func(...any).
- asasalint
# Only use ASCII chars in indentifiers
- asciicheck
# Dangerous unicode characters
- bidichk
# Checks whether HTTP response body is closed successfully.
- bodyclose
# Canonicalheader checks whether net/http.Header uses canonical header.
- canonicalheader
# TODO - do a follow up PR
# # Containedctx is a linter that detects struct contained context.Context
# # field.
# - containedctx
# TODO - do a follow up PR
# # Check whether the function uses a non-inherited context.
# - contextcheck
# Copyloopvar is a linter detects places where loop variables are copied.
- copyloopvar
# Check declaration order of types, consts, vars and funcs.
- decorder
# Check for two durations multiplied together.
- durationcheck
# Checks that sentinel errors are prefixed with the Err- and error types
# are suffixed with the -Error.
- errname
# Errorlint is a linter for that can be used to find code that will cause
# problems with the error wrapping scheme introduced in Go 1.13.
- errorlint
# Checks for pointers to enclosing loop variables.
- exportloopref
# Detects nested contexts in loops.
- fatcontext
# Checks that go compiler directive comments (//go:) are valid.
- gocheckcompilerdirectives
# Provides diagnostics that check for bugs, performance and style issues.
# Extensible without recompilation through dynamic rules.
# Dynamic rules are written declaratively with AST patterns, filters,
# report message and optional suggestion.
- gocritic
# Gofmt checks whether code was gofmt-ed. By default this tool runs
# with -s option to check for code simplification.
- gofmt
# Gofumpt checks whether code was gofumpt-ed.
- gofumpt
# Check import statements are formatted according to the 'goimport'
# command. Reformat imports in autofix mode.
- goimports
# See config below
- gomodguard
# Inspects source code for security problems.
- gosec
# Linter that specializes in simplifying code.
- gosimple
- govet
# Intrange is a linter to find places where for loops could make use of
# an integer range.
- intrange
# Checks key value pairs for common logger libraries (kitlog,klog,logr,zap).
- loggercheck
# Finds slice declarations with non-zero initial length.
- makezero
# Reports wrong mirror patterns of bytes/strings usage
- mirror
# Finds commonly misspelled English words.
- misspell
# Finds the code that returns nil even if it checks that the error is not nil.
- nilerr
# Finds sending HTTP request without context.Context.
- noctx
# Reports ill-formed or insufficient nolint directives.
- nolintlint
# Checks for misuse of Sprintf to construct a host with port in a URL.
- nosprintfhostport
# Checks that fmt.Sprintf can be replaced with a faster alternative.
- perfsprint
# Finds slice declarations that could potentially be pre-allocated.
- prealloc
# Reports direct reads from proto message fields when getters should be used.
- protogetter
# Checks that package variables are not reassigned.
- reassign
# Fast, configurable, extensible, flexible, and beautiful linter for
# Go. Drop-in replacement of golint.
- revive
# Checks for mistakes with OpenTelemetry/Census spans.
- spancheck
# Stylecheck is a replacement for golint.
- stylecheck
# Tenv is analyzer that detects using os.Setenv instead of t.Setenv
# since Go1.17.
- tenv
# Linter checks if examples are testable (have an expected output).
- testableexamples
# Remove unnecessary type conversions.
- unconvert
# Reports unused function parameters and results in your code.
- unparam
# A linter that detect the possibility to use variables/constants from the
# Go standard library.
- usestdlibvars
# Finds wasted assignment statements.
- wastedassign
# Whitespace is a linter that checks for unnecessary newlines at the start
# and end of functions, if, for, etc.
- whitespace