-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.golangci.yml
More file actions
281 lines (242 loc) · 6.83 KB
/
Copy path.golangci.yml
File metadata and controls
281 lines (242 loc) · 6.83 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
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
# golangci-lint configuration
# https://golangci-lint.run/usage/configuration/
run:
# Timeout for analysis
timeout: 5m
# Include test files
tests: true
# List of build tags to use
build-tags:
- integration
# Which directories to skip
skip-dirs:
- vendor
- third_party
- testdata
- examples
- generated
# Which files to skip
skip-files:
- ".*\\.pb\\.go$"
- ".*\\.gen\\.go$"
- "mock_.*\\.go$"
linters:
enable-all: false
enable:
# Default linters
- errcheck # Checking for unchecked errors
- gosimple # Simplify code
- govet # Vet examines Go source code
- ineffassign # Detects ineffectual assignments
- staticcheck # Static analysis
- typecheck # Type-checking
- unused # Checks for unused code
# Additional useful linters
- bodyclose # Checks HTTP response body is closed
- dogsled # Checks assignments with too many blank identifiers
- dupl # Code clone detection
- exportloopref # Checks for pointers to enclosing loop variables
- gci # Controls Go package import order
- gocognit # Cognitive complexity
- goconst # Finds repeated strings
- gocritic # Opinionated Go source code linter
- gocyclo # Cyclomatic complexity
- godot # Check if comments end in period
- godox # Detects TODO/FIXME comments
- gofmt # Checks formatting
- goimports # Checks imports
- gomnd # Detects magic numbers
- goprintffuncname # Checks Printf-like functions are named with 'f'
- gosec # Security problems
- lll # Long lines
- misspell # Finds misspelled English words
- nakedret # Finds naked returns
- noctx # Finds HTTP requests without context.Context
- nolintlint # Reports ill-formed or insufficient nolint directives
- prealloc # Finds slice declarations that could be preallocated
- revive # Fast, configurable, extensible linter
- rowserrcheck # Checks if sql.Rows.Err is checked
- sqlclosecheck # Checks sql.Rows and sql.Stmt are closed
- stylecheck # Stylecheck
- tparallel # Detects inappropriate usage of t.Parallel()
- unconvert # Unnecessary type conversions
- unparam # Unused function parameters
- whitespace # Detects leading and trailing whitespace
# Go 1.22+ specific
- copyloopvar # Detects loop variable issues (Go 1.22+)
- intrange # Finds integer range loop issues
# Dependency management
- depguard # Checks if package imports are allowed
- gomodguard # Allow/block module versions
disable:
- deadcode # Deprecated
- structcheck # Deprecated
- varcheck # Deprecated
- ifshort # Deprecated
- golint # Deprecated
- maligned # Deprecated
- scopelint # Deprecated
- exhaustivestruct # Too strict
- exhaustive # Too strict for general use
- wsl # Too opinionated about whitespace
- nlreturn # Too opinionated about newlines
- gochecknoglobals # We use globals sparingly
- gochecknoinits # Init functions are sometimes necessary
linters-settings:
# Error checking
errcheck:
check-type-assertions: true
check-blank: true
exclude-functions:
- (io.Closer).Close
- (io.ReadCloser).Close
# Cognitive complexity
gocognit:
min-complexity: 30
# Cyclomatic complexity
gocyclo:
min-complexity: 15
# Duplicate code detection
dupl:
threshold: 150
# Import ordering
gci:
sections:
- standard
- default
- prefix(github.com/carlisia/mcp-factcheck)
section-separators:
- newline
# Magic numbers
gomnd:
settings:
mnd:
checks:
- argument
- case
- condition
- operation
- return
- assign
ignored-numbers:
- '0'
- '1'
- '2'
- '10'
- '100'
ignored-functions:
- 'make'
- 'len'
- 'cap'
# Line length
lll:
line-length: 120
tab-width: 4
# Misspell
misspell:
locale: US
# Naked returns
nakedret:
max-func-lines: 30
# Preallocation
prealloc:
simple: true
range-loops: true
for-loops: true
# Revive
revive:
rules:
- name: blank-imports
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
- name: error-return
- name: error-strings
- name: error-naming
- name: if-return
- name: increment-decrement
- name: var-naming
- name: var-declaration
- name: package-comments
- name: range
- name: receiver-naming
- name: time-naming
- name: unexported-return
- name: indent-error-flow
- name: errorf
# Unparam
unparam:
check-exported: false
# Whitespace
whitespace:
multi-if: true
multi-func: true
# Godox (TODO/FIXME detection)
godox:
keywords:
- TODO
- FIXME
- HACK
- BUG
- OPTIMIZE
- XXX
# Depguard - control allowed imports
depguard:
rules:
main:
deny:
- pkg: "github.com/pkg/errors"
desc: "Use stdlib errors with fmt.Errorf and errors.New"
- pkg: "io/ioutil"
desc: "Use io or os package instead (deprecated in Go 1.16+)"
# Gomodguard - control module versions
gomodguard:
blocked:
modules:
- github.com/golang/protobuf:
recommendations:
- google.golang.org/protobuf
reason: "Use google.golang.org/protobuf for new code"
issues:
# Exclude some linters from running on tests files
exclude-rules:
- path: _test\.go
linters:
- dupl
- gomnd
- lll
- godox
- path: test/
linters:
- dupl
- gomnd
- godox
# Exclude some specific issues
- text: "Using the variable on range scope .* in function literal"
linters:
- scopelint
# Exclude TODO/FIXME in test files
- path: _test\.go
text: "TODO|FIXME"
linters:
- godox
# Maximum issues count per one linter
max-issues-per-linter: 50
# Maximum count of issues with the same text
max-same-issues: 3
# Show only new issues created after git revision
# new-from-rev: HEAD~1
# Fix found issues (if it's supported by the linter)
fix: false
output:
# Output format
formats:
- format: colored-line-number
# Print lines of code with issue
print-issued-lines: true
# Print linter name in the end of issue text
print-linter-name: true
# Make output unique by line
uniq-by-line: true
# Sort results
sort-results: true