-
Notifications
You must be signed in to change notification settings - Fork 1
/
.golangci.yaml
229 lines (178 loc) · 6.38 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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
run:
modules-download-mode: readonly
linters:
disable-all: true
enable:
# (vet, vetshadow): Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string [fast: false, auto-fix: false]
- govet
# Detects when assignments to existing variables are not used [fast: true, auto-fix: false]
- ineffassign
# (megacheck): Staticcheck is a go vet on steroids, applying a ton of static analysis checks [fast: false, auto-fix: false]
- staticcheck
# Like the front-end of a Go compiler, parses and type-checks Go code [fast: false, auto-fix: false]
- typecheck
# (gas): Inspects source code for security problems [fast: false, auto-fix: false]
- gosec
# 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
# check the function whether use a non-inherited context
- contextcheck
# check declaration order and count of types, constants, variables and functions
- decorder
# Checks types passed to the json encoding functions. Reports unsupported types and optionally reports occasions, where the check for the returned error can be omitted.
- errchkjson
# 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
# check exhaustiveness of enum switch statements
- exhaustive
# checks for pointers to enclosing loop variables
- exportloopref
# finds forced type assertions
- forcetypeassert
# Gofumpt checks whether code was gofumpt-ed.
- gofumpt
# Allow and block list linter for direct Go module dependencies
- gomodguard
# Reports deeply nested if statements
# TODO(jippi): activate again
# - nestif
# Finds the code that returns nil even if it checks that the error is not nil.
- nilerr
# Checks that there is no simultaneous return of nil error and an invalid value.
- nilnil
# nlreturn checks for a new line before return and branch statements to increase code clarity
- nlreturn
# noctx finds sending http request without context.Context
- noctx
# paralleltest detects missing usage of t.Parallel() method in your Go test
- paralleltest
# Finds slice declarations that could potentially be pre-allocated
- prealloc
# find code that shadows one of Go's predeclared identifiers
- predeclared
# Checks that package variables are not reassigned
- reassign
# tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17
- tenv
# linter that makes you use a separate _test package
- testpackage
# thelper detects golang test helpers without t.Helper() call and checks the consistency of test helpers
- thelper
# tparallel detects inappropriate usage of t.Parallel() method in your Go test codes
- tparallel
# Remove unnecessary type conversions
- unconvert
# Reports unused function parameters
- unparam
# wastedassign finds wasted assignment statements.
- wastedassign
# Whitespace Linter - Forces you to use empty lines!
- wsl
- whitespace
# A linter that detect the possibility to use variables/constants from the Go standard library.
- usestdlibvars
# Checks assignments with too many blank identifiers (e.g. x, , , _, := f())
- dogsled
# check for two durations multiplied together
- durationcheck
# check for pass []any as any in variadic func(...any)
- asasalint
# Go linter that checks if package imports are in a list of acceptable packages
- depguard
# Finds commonly misspelled English words in comments
- misspell
# Align and sort struct tags consistently
- tagalign
# Reports wrong mirror patterns of bytes/strings usage.
- mirror
- dupl
- inamedparam
- perfsprint
- testifylint
- usestdlibvars
- varnamelen
linters-settings:
nestif:
min-complexity: 6
depguard:
rules:
DontUse:
deny:
- pkg: "github.com/pkg/errors"
desc: Should be replaced by standard lib errors package
# See https://golangci-lint.run/usage/linters#gosec
gosec:
includes: []
excludes: []
exhaustive:
# Program elements to check for exhaustiveness.
check:
- switch
- map
# Presence of "default" case in switch statements satisfies exhaustiveness, even if all enum members are not listed.
# Default: false
default-signifies-exhaustive: true
unparam:
check-exported: true
varnamelen:
check-return: true
check-type-param: true
ignore-names:
- err
- i
- id
- mr
- ok
- r
- tt
- w
- wg
tagalign:
# Align and sort can be used together or separately.
#
# Whether enable align. If true, the struct tags will be aligned.
# eg:
# type FooBar struct {
# Bar string `json:"bar" validate:"required"`
# FooFoo int8 `json:"foo_foo" validate:"required"`
# }
# will be formatted to:
# type FooBar struct {
# Bar string `json:"bar" validate:"required"`
# FooFoo int8 `json:"foo_foo" validate:"required"`
# }
# Default: true.
align: true
# Whether enable tags sort.
# If true, the tags will be sorted by name in ascending order.
# eg: `xml:"bar" json:"bar" validate:"required"` -> `json:"bar" validate:"required" xml:"bar"`
# Default: true
sort: true
# Specify the order of tags, the other tags will be sorted by name.
# This option will be ignored if `sort` is false.
# Default: []
order:
- expr
- graphql
# config/dependency injection
- default
- koanf
- wire
# encode and decode
- json
- yaml
- mapstructure
# misc
- validate
# Whether enable strict style.
# In this style, the tags will be sorted and aligned in the dictionary order,
# and the tags with the same name will be aligned together.
# Note: This option will be ignored if 'align' or 'sort' is false.
# Default: false
strict: true