-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.golangci.yml
311 lines (306 loc) · 10.6 KB
/
.golangci.yml
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
run:
concurrency: 4
timeout: 5m
# Do not fail, we check the output for errors with severity "critical"
issues-exit-code: 0
tests: true
output:
formats:
- format: line-number
linters:
# Disable all linters, so we enable linters explicitly
disable-all: true
enable:
### Default linters for golangci-lint
# Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases
- errcheck
# Linter for Go source code that specializes in simplifying code
- gosimple
# Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
- govet
# Detects when assignments to existing variables are not used
- ineffassign
# It's a set of rules from staticcheck
- staticcheck
# Like the front-end of a Go compiler, parses and type-checks Go code
- typecheck
# Checks Go code for unused constants, variables, functions and types
- unused
### Additional linters
# Check for pass []any as any in variadic func(...any)
- asasalint
# Simple linter to check that your code does not contain non-ASCII identifiers
- asciicheck
# Checks for dangerous unicode character sequences
- bidichk
# Checks whether HTTP response body is closed successfully
- bodyclose
# A linter that detects struct contained context.Context field
- containedctx
# Check whether the function uses a non-inherited context
- contextcheck
# Disable cyclomatic complexity - it doesn't help much, because of many error handling conditionals
# - cyclop
# Disable declaration order style check
# - decorder
# Go linter that checks if package imports are in a list of acceptable packages
- depguard
# Disable dogsled style check
# - dogsled
# Disable duplicate code style check because of false positives
# - dupl
# Disable duplicate word checks in comments
# - dupword
# Check for two durations multiplied together
- durationcheck
# Checks types passed to the json encoding functions
- errchkjson
# Checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error.
- errname
# 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
# Disable execinquery
# - execinquery
# Check exhaustiveness of enum switch statements
- exhaustive
# Disable exhaustruct since we want to have struct literals with default values
# - exhaustruct
# A linter that detects places where loop variables are copied (replacement for exportloopref)
- copyloopvar
# Forbids identifiers (e.g. fmt.Println) from being used
- forbidigo
# Finds forced type assertions
- forcetypeassert
# Disable funlen because we don't want to limit function length to a fixed length
# - funlen
# This analyzer checks for global variables and errors on any found.
- gochecknoglobals
# Checks that no init functions are present in Go code
- gochecknoinits
# Computes and checks the cognitive complexity of functions
- gocognit
# Finds repeated strings that could be replaced by a constant
- goconst
# Provides diagnostics that check for bugs, performance and style issues
- gocritic
# Disable gocyclo because we already use gocognit
# - gocyclo
# Disable godot, because we don't enforce the comments as full sentences internally
# - godot
# Disable godox for now, since we have some TODOs still pending
# - godox
# Golang linter to check the errors handling expressions
- err113
# Disable gofmt
# - gofmt
# Disable gofumpt
# - gofumpt
# Disable goheader
- goheader
# Disable goimports
# - goimports
# Disable gomnd (magic numbers) for now - too many false positives, but good idea to have
# - gomnd
# Disable gomoddirectives
# - gomoddirectives
# Disable gomodguard
# - gomodguard
# Checks that printf-like functions are named with f at the end
- goprintffuncname
# Inspects source code for security problems
- gosec
# An analyzer to analyze expression groups
- grouper
# Enforces consistent import aliases
- importas
# A linter that checks the number of methods inside an interface
- interfacebloat
# Disable ireturn
# - ireturn
# Disable lll
# - lll
# Disable loggercheck
# - loggercheck
# Measures the maintainability index of each function
- maintidx
# Finds slice declarations with non-zero initial length
- makezero
# Finds commonly misspelled English words in comments
- misspell
# Finds naked returns in functions greater than a specified function length
- nakedret
# Disable nestif
# - nestif
# Finds code that returns nil even if it checks that the error is not nil
- nilerr
# Disable nilnil
# - nilnil
# Disable nlreturn
# - nlreturn
# Finds sending http request without context.Context
- noctx
# Reports ill-formed or insufficient nolint directives
- nolintlint
# Disable nonamedreturns
# - nonamedreturns
# Checks for misuse of Sprintf to construct a host with port in a URL
- nosprintfhostport
# Disable paralleltest
# - paralleltest
# Finds slice declarations that could potentially be pre-allocated
- prealloc
# Find code that shadows one of Go's predeclared identifiers
- predeclared
# Disable promlinter
# - promlinter
# Checks that package variables are not reassigned
- reassign
# Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint.
- revive
# Disable rowserrcheck because of generics
# - rowserrcheck
# Disable sqlclosecheck because of generics
# - sqlclosecheck
# Style checker for Go source code
- stylecheck
# Disable tagliatelle because of mixed usage of cases
# - tagliatelle
# Analyzer that detects using os.Setenv instead of t.Setenv
- tenv
# Disable testableexamples because we have none
# - testableexamples
# Check tests are defined in a separate test package (_test) # TODO This is currently broken in golangci-lint
- testpackage
# Detects golang test helpers without t.Helper() call and checks the consistency of test helpers
- thelper
# Disable tparallel
# - tparallel
# Remove unnecessary type conversions
- unconvert
# Reports unused function parameters
- unparam
# A linter that detect the possibility to use variables/constants from the Go standard library
- usestdlibvars
# Checks that the length of a variable's name matches its scope
- varnamelen
# Disable wastedassign because of generics
# - wastedassign
# Detect leading and trailing whitespace
- whitespace
# Disable wrapcheck because of false positives with internal
# - wrapcheck
# Disable wsl because it would need too much code to be changed
# - wsl
linters-settings:
errcheck:
check-type-assertions: true
check-blank: true
govet:
check-shadowing: false
depguard:
rules:
main:
deny:
- pkg: github.com/pkg/errors
desc: 'use github.com/friensofgo/errors instead'
- pkg: github.com/go-errors/errors
desc: 'use github.com/friensofgo/errors instead'
- pkg: github.com/pingcap/errors
desc: 'use github.com/friensofgo/errors instead'
- pkg: github.com/apex/log
desc: 'use log/slog instead'
- pkg: log$
desc: 'use log/slog instead'
exhaustive:
default-signifies-exhaustive: true
varnamelen:
# The longest distance, in source lines, that is being considered a "small scope".
# Variables used in at most this many lines will be ignored.
max-distance: 6
# Check named return values.
check-return: true
# Optional list of variable names that should be ignored completely.
ignore-names:
- err
- id
- tc # For table driven tests
# Optional list of variable declarations that should be ignored completely.
ignore-decls:
- i int
- r io.Reader
- w io.Writer
- f *os.File
- h http.Handler
- r *http.Request
- w http.ResponseWriter
- c *cli.Context
- sb strings.Builder
- db *sql.DB
- tx *sql.Tx
- tx pgx.Tx
- q builder.SelectBuilder
stylecheck:
checks: ["ST1003"]
initialisms: ["ACL", "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "QPS", "RAM", "RPC", "SLA", "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", "UDP", "UI", "GID", "UID", "UUID", "URI", "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", "XSS", "SIP", "RTP", "AMQP", "DB", "TS", "GQL", "GLN"]
gocritic:
disabled-checks:
- ifElseChain
- singleCaseSwitch
issues:
exclude-rules:
# Allow init functions for migrations
- path: persistence/migrations
linters:
- gochecknoinits
# Allow dot imports for qrb in repositories
- path: persistence/repository
linters:
- revive
text: dot-imports
# Allow unused parameters in resolvers
- path: api/graph
linters:
- revive
text: unused-parameter
# Exclude some linters from running on tests files.
- path: _test\.go
linters:
- bodyclose
- errcheck
- forcetypeassert
- gocognit
- goconst
- gocritic
- err113
- gosec
- maintidx
- prealloc
- revive
- staticcheck
- thelper
- varnamelen
- linters:
- stylecheck
text: "ST1003: should not use underscores in Go names"
- linters:
- gochecknoglobals
path: _test\.go
severity:
# Set the default severity for issues.
#
# If severity rules are defined and the issues do not match or no severity is provided to the rule
# this will be the default severity applied.
# Severities should match the code climate naming (see https://docs.codeclimate.com/docs/issues#issue-severity).
default-severity: blocker
# If set to true `severity-rules` regular expressions become case-sensitive.
case-sensitive: false
# When a list of severity rules are provided, severity information will be added to lint issues.
# Severity rules have the same filtering capability as exclude rules
# except you are allowed to specify one matcher per severity rule.
# Only affects out formats that support setting severity information.
rules:
- linters:
- varnamelen
- nolintlint
- gocognit
severity: minor