-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path.golangci.yml
More file actions
239 lines (221 loc) · 7.1 KB
/
Copy path.golangci.yml
File metadata and controls
239 lines (221 loc) · 7.1 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
version: "2"
run:
timeout: 5m
# Build tags used in the project (if any) — leave empty for now.
tests: true
# Don't fail on go.mod version mismatch with the installed Go toolchain.
go: ""
output:
formats:
text:
path: stderr
print-linter-name: true
print-issued-lines: true
linters:
default: none
enable:
# --- Correctness & bugs ---
- errcheck # unchecked errors
- govet # standard vet checks
- staticcheck # SA/ST/QF megachecks
- ineffassign # ineffectual assignments
- unused # unused code (funcs, vars, consts, fields)
- bodyclose # http.Response.Body must be closed
- durationcheck # time.Duration multiplication mistakes
- errorlint # proper error wrapping / errors.Is/As usage
- nilerr # `return nil` when err != nil
- noctx # net/http requests without context
- rowserrcheck # sql.Rows.Err must be checked
- sqlclosecheck # sql.Rows / sql.Stmt must be closed
- copyloopvar # Go 1.22+ loop variable capture
- gocheckcompilerdirectives # `//go:` directive typos
- reassign # reassigning top-level pkg vars (errors.EOF, etc.)
- makezero # `make([]T, len)` then append — usually a bug
# --- Security ---
- gosec # security audit — REQUIRED by maintainer
- bidichk # forbid trojan-source bidirectional unicode
# --- Style / readability ---
- gocritic # broad set of opinionated checks
- revive # configurable golint successor
- misspell # english spelling
- unconvert # remove redundant type conversions
- whitespace # leading/trailing whitespace in funcs
- nakedret # naked returns in long funcs
- prealloc # preallocate slices in obvious loops
- usestdlibvars # use stdlib consts (http.MethodGet, etc.)
settings:
errcheck:
check-type-assertions: false
check-blank: false
# Common functions where ignoring the error is conventional.
exclude-functions:
- (*os.File).Close
- (io.Closer).Close
- (net.Conn).Close
- (net.Listener).Close
- (*database/sql.Rows).Close
- (*database/sql.Stmt).Close
- fmt.Fprint
- fmt.Fprintf
- fmt.Fprintln
govet:
enable-all: true
disable:
- fieldalignment # too noisy; only useful for hot-path structs
- shadow # too many false positives in idiomatic Go
staticcheck:
checks:
- all
# Examples to disable specific noisy checks (kept enabled by default):
# - "-ST1000" # missing package doc
# - "-ST1003" # naming conventions (too opinionated for legacy code)
gosec:
severity: low
confidence: low
excludes:
- G104 # "Errors unhandled" — errcheck covers this with better config
- G115 # Integer overflow conversion — many false positives on slice lengths
# G124 ("Cookie missing Secure/HttpOnly/SameSite") triggers even when
# the attributes are set through a struct field instead of a literal —
# gosec's pattern only matches inline true/false. Every cookie in this
# codebase sets all three attributes (HttpOnly, Secure via configurable
# field, SameSite); validated by code review.
- G124
# G710 ("Open redirect via taint analysis") flags every
# http.Redirect(..., "/ui/...") + chi URLParam combination as tainted.
# All redirects in this app are same-origin relative paths (no scheme
# or host accepted); validated by code review of internal/web/*.
- G710
config:
G306: "0644" # acceptable file perm for non-secret files
gocritic:
enabled-tags:
- diagnostic
- style
- performance
- opinionated
disabled-checks:
- hugeParam # noisy for value receivers used in tests
- rangeValCopy # noisy on small structs
- typeDefFirst # style preference
- paramTypeCombine # style preference
- unnamedResult # too opinionated
- whyNoLint # explanations not required
- commentedOutCode
revive:
enable-all-rules: false
severity: warning
rules:
- name: atomic
- name: blank-imports
- name: bool-literal-in-expr
- name: confusing-naming
- name: confusing-results
- name: constant-logical-expr
- name: context-as-argument
- name: context-keys-type
- name: defer
arguments:
- - immediate-recover
- recover
- return
- name: duplicated-imports
- name: early-return
- name: empty-block
- name: error-naming
- name: error-return
- name: error-strings
- name: errorf
- name: identical-branches
- name: if-return
- name: increment-decrement
- name: indent-error-flow
- name: range
- name: range-val-in-closure
- name: receiver-naming
- name: redefines-builtin-id
- name: string-of-int
- name: superfluous-else
- name: time-equal
- name: time-naming
- name: unconditional-recursion
- name: unexported-return
- name: unnecessary-stmt
- name: unreachable-code
- name: unused-parameter
disabled: true # too noisy; gopls/unparam already cover the useful cases
- name: useless-break
- name: var-declaration
- name: var-naming
- name: waitgroup-by-value
misspell:
locale: US
nakedret:
max-func-lines: 30
prealloc:
simple: true
range-loops: true
for-loops: false
unparam:
check-exported: false
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
paths:
- third_party$
- builtin$
- examples$
- bin$
- \.tools$
rules:
# Tests can be more relaxed: random for fixtures, hardcoded creds, file perms.
- path: _test\.go
linters:
- errcheck
- gosec
- gocritic
- bodyclose
- noctx
- prealloc
- unparam
- rowserrcheck
- sqlclosecheck
- path: tests/integration/
linters:
- errcheck
- gosec
- gocritic
- bodyclose
- noctx
- prealloc
- unparam
# Generated/embedded asset wrappers tend to trip stylistic linters.
- path: internal/web/templates/
linters:
- gocritic
- revive
formatters:
enable:
- gofmt
- goimports
settings:
goimports:
local-prefixes:
- github.com/forgekeep/nebula-mesh
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
- bin$
- \.tools$
issues:
max-issues-per-linter: 0
max-same-issues: 0
# Show all issues from new linters even if they hit older code.
new: false