-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path.golangci.yml
More file actions
204 lines (187 loc) · 5.5 KB
/
Copy path.golangci.yml
File metadata and controls
204 lines (187 loc) · 5.5 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
# golangci-lint configuration for ZeBGP (v2 format)
version: "2"
run:
timeout: 10m
# Lint the feature-rich shipped build (ze + ze-appliance feature set): ze_core
# plus every default-on per-feature compile-out tag. This gives the
# //go:build ze_<feature> registration + factory files real lint coverage and
# prevents their registry callers (e.g. registerService) from being reported
# as unused.
#
# This list is static YAML (golangci-lint cannot read feature-gates.txt), so it
# is the ONE feature-gate consumer that does not self-derive. It MUST equal
# ze_core + every gate tag in feature-gates.txt; `dep_audit.py --check` fails on
# drift. When you add a gate to feature-gates.txt, add its tag here too.
# See ai/rules/plugins.md.
build-tags:
- ze_core
- ze_lg
- ze_ssh
- ze_web
- ze_gnmi
- ze_mcp
- ze_rest
- ze_grpc
- ze_telemetry
- ze_isis
- ze_ldp
- ze_ospf
- ze_rsvpte
- ze_vrrp
- ze_ntp
- ze_flowexport
- ze_ddos
- ze_anomaly
- ze_as112
- ze_geodns
- ze_dhcpserver
- ze_pxe
- ze_trafficusage
- ze_policyroute
- ze_cos
- ze_copp
- ze_mpls
- ze_tacacs
- ze_exabgp
- ze_bfd
- ze_vpp
- ze_ike
- ze_l2tp
- ze_radius
- ze_mrt
- ze_bgp
- ze_bmp
linters:
exclusions:
rules:
- path: _test\.go
linters:
- dupl
- goconst
- gosec
- prealloc
- path: cmd/
linters:
- forbidigo
- linters:
- staticcheck
text: "QF1008"
# Bubbletea tea.Model interface requires value receivers — cannot use pointer
- path: "(internal/component/cli/model[^/]*|cmd/ze/cli/main)\\.go"
text: "hugeParam"
# slog.Handler interface requires slog.Record by value — cannot use pointer
- path: "internal/core/slogutil/color\\.go"
text: "hugeParam"
enable:
# Core linters
- errcheck
- govet
- ineffassign
- staticcheck
- unused
# Additional linters
- forbidigo
- gocritic
- gosec
- misspell
- unconvert
- unparam
- nakedret
- prealloc
- noctx
- bodyclose
- dupl
- errorlint
- exhaustive
- forcetypeassert
- goconst
- godot
- nilerr
- nilnil
- tparallel
- wastedassign
# Modernization linters
- intrange
- modernize
settings:
errcheck:
check-type-assertions: true
check-blank: false
exclude-functions:
- "(*strings.Builder).Write"
- "(*strings.Builder).WriteByte"
- "(*strings.Builder).WriteRune"
- "(*strings.Builder).WriteString"
- "(*github.com/ze-software/ze/internal/core/textbuf.Buffer).Write"
- "(*github.com/ze-software/ze/internal/core/textbuf.Buffer).WriteByte"
- "(*github.com/ze-software/ze/internal/core/textbuf.Buffer).WriteRune"
- "(*github.com/ze-software/ze/internal/core/textbuf.Buffer).WriteString"
govet:
disable:
- fieldalignment
gocritic:
enabled-tags:
- diagnostic
- style
- performance
disabled-checks:
- builtinShadow
- commentedOutCode
- importShadow
- unnamedResult
settings:
hugeParam:
# ospfConfig is an intentionally-copied immutable config snapshot passed by value
# across the OSPF package (setConfig/reconcile/forInstance and ~20 read helpers).
# Each OSPF spec that adds a config field grows it; the threshold has tracked that
# growth (256 -> 280 -> 288) rather than converting the snapshot pattern to pointers.
sizeThreshold: 288
rangeValCopy:
sizeThreshold: 160
gosec:
excludes:
- G104 # Errors unhandled — checked by errcheck linter instead
- G115 # Integer overflow conversion — intentional byte extraction in wire encoding
- G602 # Slice index out of range — false positives on bounded loops
- G703 # Path traversal — XDG config resolution uses env vars by design
- G704 # SSRF via taint — false positive on URL construction from constants
- G705 # XSS via taint — false positive on fmt.Fprintf to os.Stderr / io.Writer
- G706 # Log injection via taint — false positive on slog structured logging
misspell:
# US spelling is the codebase convention (neighbor 1833:3, behavior 423:0, ...).
locale: US
nakedret:
max-func-lines: 30
prealloc:
simple: true
range-loops: true
dupl:
threshold: 150
goconst:
min-len: 3
min-occurrences: 3
exhaustive:
default-signifies-exhaustive: true
forbidigo:
analyze-types: true
forbid:
# Legacy log package is forbidden; use log/slog (ai/rules/go-standards.md).
# NOTE: forbidigo matches identifiers/selectors only, never call
# arguments, so `os.Getenv("ZE_...")` cannot be expressed here; a
# blanket os.Getenv ban would flood legitimate system-var reads
# (HOME, PATH, ...). Ze env access (internal/core/env only) is
# enforced by ai/rules/go-standards.md and the edit hooks instead.
- pattern: '^log\.(Print|Printf|Println|Fatal|Fatalf|Fatalln|Panic|Panicf|Panicln)$'
pkg: '^log$'
msg: "use log/slog -- ai/rules/go-standards.md"
formatters:
enable:
- gofmt
- goimports
settings:
goimports:
local-prefixes:
- github.com/ze-software/ze
issues:
max-issues-per-linter: 50
max-same-issues: 10