-
Notifications
You must be signed in to change notification settings - Fork 288
Expand file tree
/
Copy path.golangci.yml
More file actions
196 lines (183 loc) · 6.87 KB
/
.golangci.yml
File metadata and controls
196 lines (183 loc) · 6.87 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
version: "2"
formatters:
enable:
- gci
- gofumpt
settings:
gci:
sections:
- standard
- default
- prefix(github.com/e2b-dev/infra)
linters:
default: all
disable:
# todo: determine if we want this
- canonicalheader
- cyclop
- dupl
- dupword
- errcheck
- exhaustive
- exhaustruct
- funcorder
- funlen
- gochecknoglobals
- gochecknoinits
- gocognit
- goconst
- gocyclo
- godot
- godox
- gomoddirectives
- gomodguard
- gosec
- ireturn
- lll
- maintidx
- mnd
- nestif
- nilnil
- noinlineerr
- nonamedreturns
- nosprintfhostport
- prealloc
- predeclared
- tagliatelle
- testpackage
- varnamelen
- wrapcheck
# todo: enable these
- err113
- forcetypeassert
- godoclint
# deprecated, remove when golangci-lint makes us
- wsl
- wsl_v5
settings:
forbidigo:
forbid:
- pattern: "^new$"
msg: "Use &Type{} instead."
# - pattern: os\.Getenv
# msg: "Add your field to the configuration model instead."
- pattern: 'zap\.New$'
pkg: '^go\.uber\.org/zap$'
msg: "Use github.com/e2b-dev/infra/packages/shared/pkg/logger instead of zap.New()"
- pattern: 'zap\.NewProduction$'
pkg: '^go\.uber\.org/zap$'
msg: "Use github.com/e2b-dev/infra/packages/shared/pkg/logger instead of zap.NewProduction()"
- pattern: 'zap\.NewDevelopment$'
pkg: '^go\.uber\.org/zap$'
msg: "Use github.com/e2b-dev/infra/packages/shared/pkg/logger instead of zap.NewDevelopment()"
- pattern: 'zap\.NewExample$'
pkg: '^go\.uber\.org/zap$'
msg: "Use github.com/e2b-dev/infra/packages/shared/pkg/logger instead of zap.NewExample()"
- pattern: 'zap\.L$'
msg: "Use github.com/e2b-dev/infra/packages/shared/pkg/logger.L() instead of zap.L()"
- pattern: 'zap\.S$'
pkg: '^go\.uber\.org/zap$'
msg: "Use github.com/e2b-dev/infra/packages/shared/pkg/logger instead of zap.S()"
- pattern: 'zap\.NewNop$'
pkg: '^go\.uber\.org/zap$'
msg: "Use github.com/e2b-dev/infra/packages/shared/pkg/logger.NewNopLogger() instead of zap.NewNop()"
- pattern: 'zap\.Time$'
pkg: '^go\.uber\.org/zap$'
msg: "Use github.com/e2b-dev/infra/packages/shared/pkg/logger.Time() instead of zap.Time()"
# prefer methods that take a context to those that don't
- pattern: '^retryablehttp\.NewRequest$'
pkg: ^github\.com/hashicorp/go-retryablehttp$
msg: "Use github.com/hashicorp/go-retryablehttp.NewRequestWithContext instead of retryablehttp.NewRequest"
- pattern: 'gin\.SetMode'
pkg: '^github\.com/gin-gonic/gin$'
msg: "Do not use gin.SetMode(gin.TestMode) - it causes race conditions. GIN_MODE=test is set in CI workflows."
analyze-types: true
depguard:
rules:
no-pprof-default-mux:
files:
- $all
- "!**/packages/shared/pkg/telemetry/**"
deny:
- pkg: "net/http/pprof"
desc: "Importing net/http/pprof registers on DefaultServeMux via init(). Use telemetry.NewPprofMux() instead."
nolintlint:
# We are temporarily allowing unused nolints due to apparently
# false failures in CI. See
# https://github.com/golangci/golangci-lint/issues/3228
allow-unused: true
perfsprint:
# Scoped to `errorf` only: enforce `errors.New` over `fmt.Errorf("static")`.
# Other perfsprint checks are intentionally disabled to keep this rule surgical.
# Can be broadened later in a follow-up.
error-format: true
errorf: true
err-error: false
integer-format: false
int-conversion: false
string-format: false
sprintf1: false
strconcat: false
bool-format: false
hex-format: false
concat-loop: false
gocritic:
disabled-checks:
- appendAssign
revive:
enable-all-rules: true
rules:
- { disabled: true, name: add-constant } # todo: enable this
- { disabled: true, name: argument-limit }
- { disabled: true, name: bare-return }
- { disabled: true, name: bool-literal-in-expr }
- { disabled: true, name: cognitive-complexity }
- { disabled: true, name: comment-spacings }
- { disabled: true, name: confusing-naming }
- { disabled: true, name: confusing-results }
- { disabled: true, name: context-as-argument }
- { disabled: true, name: cyclomatic }
- { disabled: true, name: deep-exit }
- { disabled: true, name: enforce-switch-style }
- { disabled: true, name: exported }
- { disabled: true, name: flag-parameter } # todo: enable this
- { disabled: true, name: function-length }
- { disabled: true, name: function-result-limit }
- { disabled: true, name: get-return }
- { disabled: true, name: identical-branches } # todo: enable this
- { disabled: true, name: identical-switch-branches } # todo: enable this
- { disabled: true, name: import-alias-naming }
- { disabled: true, name: import-shadowing }
- { disabled: true, name: line-length-limit }
- { disabled: true, name: max-control-nesting }
- { disabled: true, name: max-public-structs }
- { disabled: true, name: nested-structs }
- { disabled: true, name: package-comments }
- { disabled: true, name: package-directory-mismatch }
- { disabled: true, name: unchecked-type-assertion }
- { disabled: true, name: unexported-naming }
- { disabled: true, name: unhandled-error } # todo: enable this
- { disabled: true, name: unnecessary-format } # todo: enable this
- { disabled: true, name: unnecessary-stmt } # todo: enable this
- { disabled: true, name: unsecure-url-scheme }
- { disabled: true, name: unused-receiver }
- { disabled: true, name: use-errors-new } # todo: enable this
- { disabled: true, name: use-waitgroup-go } # todo: enable this
- { disabled: true, name: var-declaration }
- { disabled: true, name: var-naming }
staticcheck:
checks:
- all
- -S1002 # Omit comparison with boolean constant
- -SA1019 # TODO: Remove (Using a deprecated function, variable, constant or field)
- -ST1000 # Incorrect or missing package comment
- -ST1020 # The documentation of an exported function should start with the function’s name
- -ST1021 # The documentation of an exported type should start with type’s name
- -ST1003 # Poorly chosen identifier
- -QF1008 # Omit embedded fields from selector expression
run:
go: 1.25.9
allow-parallel-runners: true
issues:
max-issues-per-linter: 50
max-same-issues: 50