-
Notifications
You must be signed in to change notification settings - Fork 0
/
.golangci.yml
206 lines (157 loc) · 4.42 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
run:
tests: true
build-tags:
- integration
output:
uniq-by-line: false
sort-results: true
print-linter-name: true
issues:
# Show all issues in the project
max-issues-per-linter: 0
max-same-issues: 0
new: false
# Linters & linter-settings inspired by https://olegk.dev/go-linters-configuration-the-right-version
linters:
enable:
# Check for passing []any as any in variadic func(...any).
- asasalint
# Prefer plain ASCII identifiers.
# I.e. - use `delta` in place of `∆`
# TODO - enable
# - asciicheck
# Checks for dangerous unicode character sequences.
- bidichk
# Check that HTTP response bodies are closed
- bodyclose
# Check whether the function uses a non-inherited context.
- contextcheck
# Check for two durations multiplied together.
- durationcheck
# Forces to not skip error check.
- errcheck
# Checks `Err-` prefix for var and `-Error` suffix for error type.
- errname
# Suggests to use `%w` for error-wrapping.
# TODO - enable
- errorlint
# Checks for pointers to enclosing loop variables.
- exportloopref
# TODO - enable
# - gocritic
# lint comments
# TODO - enable
# - godot
# Make sure everything's auto-formatted
- gofmt
- gofumpt
- goimports
# Handle replace, retract, exclude directives in go.mod
- gomoddirectives
# Security-oriented linter
# TODO - enable
# - gosec
# Simplify code
- gosimple
# Official go linter
- govet
# Detects when assignments to existing variables are unused
- ineffassign
# Check for misspellings
- misspell
# Finds naked/bare returns
- nakedret
# Both require a bit more explicit returns.
- nilerr
- nilnil
# Finds sending HTTP request without context.Context.
# TODO - enable
# - noctx
# Forces comment why another check is disabled.
# Better not to have //nolint: at all ;)
- nolintlint
# Finds slices that could potentially be pre-allocated.
# - prealloc
# Finds shadowing of Go's predeclared identifiers.
# I hear a lot of complaints from junior developers.
# But after some time they find it very useful.
- predeclared
# Lint your Prometheus metrics name.
- promlinter
# Checks that package variables are not reassigned.
# Super rare case but can catch bad things (like `io.EOF = nil`)
- reassign
# Drop-in replacement of `golint`
# TODO - enable
# - revive
# Somewhat similar to `bodyclose` but for `database/sql` package.
# TODO - enable
# - rowserrcheck
- sqlclosecheck
- staticcheck
# Checks function and package cyclomatic complexity
# Cyclomatic complexity is a measurement, not a goal.
# TODO - enable
# - cyclop
- typecheck
# Is a replacement for `golint`, similar to `revive`.
# TODO - enable
# - stylecheck
# Check struct tags.
- tagliatelle
# Test-related checks.
- tenv
- testableexamples
- thelper
- tparallel
# Remove unnecessary type conversions, make code cleaner
- unconvert
# Might be noisy but better to know what is unused
# TODO - enable
# - unparam
# Must have. Finds unused declarations.
- unused
# Detect the possibility to use variables/constants from stdlib.
# TODO - enable
- usestdlibvars
# Finds wasted assignment statements.
- wastedassign
linters-settings:
# See https://go-critic.com/overview.html
gocritic:
enabled-tags:
- diagnostic
# - experimental
- opinionated
- performance
- style
disabled-checks:
# These 3 detect many cases and are mostly useful for helping optimize for
# performance oriented code
- hugeParam
- rangeExprCopy
- rangeValCopy
errcheck:
# Report `a := b.(MyStruct)` when `a, ok := ...` should be.
# TODO - enable
# check-type-assertions: true # Default: false
# Report skipped checks:`num, _ := strconv.Atoi(numStr)`.
# TODO - enable
# check-blank: true # Default: false
# Function to skip.
exclude-functions:
- io/ioutil.ReadFile
- io.Copy(*bytes.Buffer)
- io.Copy(os.Stdout)
nakedret:
# No naked returns
max-func-lines: 1 # Default: 30
tagliatelle:
case:
rules:
json: snake
yaml: snake
xml: camel
bson: camel
avro: snake
mapstructure: kebab