-
Notifications
You must be signed in to change notification settings - Fork 0
/
.golangci.yml
205 lines (203 loc) · 5.9 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
run:
# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 2m
linters:
disable-all: true
enable:
# enabled by default
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- unused
# disabled by default
- asasalint
- asciicheck
- bidichk
- bodyclose
- containedctx
- contextcheck
- copyloopvar
- cyclop
# - deadcode [deprecated]
- decorder
# - depguard # not using whitelist of external packages
- dogsled
- dupl
- dupword
- durationcheck
- errchkjson
- errname
- errorlint
- execinquery
- exhaustive
# - exhaustivestruct [deprecated]
# - exhaustruct # use constructors to handle empty fields instead of tags
- exportloopref
- forbidigo
- forcetypeassert
- funlen
- gci
# - ginkgolinter # not using ginkgo
- gocheckcompilerdirectives
# - gochecknoglobals # globals are ok
# - gochecknoinits # init() is ok
- gochecksumtype
- gocognit
- goconst
- gocritic
- gocyclo
# - godot # comments without periods are fine
- godox
# - goerr113 # want non-stick errors
- gofmt
# - gofumpt # too strict formatting
# - goheader # not using a header
- goimports
# - golint [deprecated]
# - gomnd # magic numbers are ok
- gomoddirectives
# - gomodguard # not using whitelist of external packages
- goprintffuncname
- gosec
# - gosmopolitan # not using i18n, using it on front end
- grouper
# - ifshort [deprecated]
- importas
- inamedparam
- interfacebloat
# - interfacer [deprecated]
- intrange
# - ireturn # return interfaces are fine
- lll
# - loggercheck # not using these logs
- maintidx
- makezero
# - maligned [deprecated]
- mirror
- misspell
- musttag
- nakedret
- nestif
- nilerr
- nilnil
# - nlreturn # don't need newline before return
- noctx
# - nolintlint # need this
- nonamedreturns
# - nosnakecase [deprecated]
- nosprintfhostport
# - paralleltest # not making every test parallel
- perfsprint
- prealloc
- predeclared
# - promlinter # not using prometheus
- protogetter
- reassign
- revive
- rowserrcheck
# - scopelint [deprecated]
- sloglint
- spancheck
- sqlclosecheck
# - structcheck [deprecated]
- stylecheck
- tagalign
- tagliatelle
- tenv
# - testableexamples # no output comments are ok
- testifylint
# - testpackage # _test packages are not preferred
# - thelper # no need to clean up call stack for tests
- tparallel
- unconvert
- unparam
- usestdlibvars
# - varcheck [deprecated]
# - varnamelen # short names are fine
- wastedassign
- whitespace
# - wrapcheck # don't want to always wrap errors
# - wsl # too strict whitespace stuff
# - zerologlint # not using zerolog
# all available settings of specific linters
linters-settings:
lll:
# Max line length, lines longer will be reported.
# '\t' is counted as 1 character by default, and can be changed with the tab-width option.
# Default: 120.
line-length: 150
# Tab width in spaces.
# Default: 1
tab-width: 1
cyclop:
# The maximal code complexity to report.
# Default: 10
max-complexity: 16
errorlint:
# Check for plain error comparisons.
# Default: true
comparison: false
forbidigo:
# Forbid the following identifiers (list of regexp).
# Default: ["^(fmt\\.Print(|f|ln)|print|println)$"]
forbid:
- "^(fmt\\.Print(|f|ln)|print|println)$"
- "^(slog\\.(Debug|Info|Warn|Error)(Context)?)$"
- "^(slog\\.Default)$"
- "^(logg\\.Default)$"
- "^(context\\.Background)$"
gci:
# Section configuration to compare against.
# Section names are case-insensitive and may contain parameters in ().
# The default order of sections is `standard > default > custom > blank > dot`,
# If `custom-order` is `true`, it follows the order of `sections` option.
# Default: ["standard", "default"]
sections:
- standard # Standard section: captures all standard packages.
- default # Default section: contains all imports that could not be matched to another section type.
- prefix(github.com/s12chung/text2anki) # Custom section: groups all imports with the specified Prefix.
tagliatelle:
# Check the struct tag name case.
case:
# `camel` is used for `json` and `yaml`, and `header` is used for `header` (can be overridden)
# Default: {}
rules:
# Any struct tag type can be used.
# Support string case: `camel`, `pascal`, `kebab`, `snake`, `goCamel`, `goPascal`, `goKebab`, `goSnake`, `upper`, `lower`, `header`
json: snake
issues:
# golangci has its own rules to ignore certain lint rules. See `golangci-lint run --help`.
# Default value for this option is true.
exclude-use-default: false
exclude-rules:
# code for humans instead of machines until you scale up
- text: fieldalignment
linters:
- govet
# I like my zeros
- text: "var-declaration: should drop = 0 from declaration of var"
linters:
- revive
# easier to manipulate, even if longer
- text: "if-return: redundant if ...; err != nil check, just return error instead"
linters:
- revive
# it's fine in tests
- text: "context.Background"
path: '(.+)_test\.go'
linters:
- forbidigo
# Does not apply for go 1.22
- text: "G601: Implicit memory aliasing in for loop."
linters:
- gosec
# context is not needed, should be used in the wrapper function
- source: 'jhttp\.ReturnModelOr500\(func\(\) \(any, error\)'
linters:
- contextcheck
# context is not needed, should be used in the wrapper function
- source: 'rs\.runOr500\(r, func\(r \*http\.Request, tx db\.TxQs\) error'
linters:
- contextcheck