Commit 6dc9591
authored
refactor: reduce mid-tier oversized functions across services (#2028)
* refactor(current-account): reduce oversized functions
Extract helpers from 15 oversized functions in the current-account
service layer including saga handlers, valuation engine, orchestrators,
and gRPC endpoints.
* refactor(payment-order): reduce oversized functions
Extract helpers from saga handlers, orchestrator ledger/lien/saga,
gRPC lifecycle and update endpoints, and invoice generator.
* refactor(position-keeping): reduce oversized functions
Extract helpers from persistence repositories, balance service,
gRPC log endpoints, and initiation handlers.
* refactor(reconciliation): reduce oversized functions
Extract helpers from gRPC endpoints, pipeline service, balance
assertor, variance detector, settlement ingestor, and snapshot capturer.
* refactor(control-plane): reduce oversized functions
Extract helpers from applier, generator, manifest handler, validators,
staff service, stripe webhook/reconciliation, and balance sheet.
* refactor(internal-account): reduce oversized functions
Extract helpers from persistence mappers/repository, gRPC endpoints,
lien service, valuation engine, and valuation feature service.
* refactor(tenant): reduce oversized functions
Extract helpers from provisioner, gRPC endpoints, alerting worker,
and provisioning worker.
* refactor(shared): reduce oversized functions
Extract helpers from saga executor, step execution, causation tree,
starlark runner, valuation runtime, audit, and auth config.
* refactor(services): reduce oversized functions in smaller services
Extract helpers from mcp-server, audit-worker, event-router,
financial-accounting, financial-gateway, forecasting, identity,
and party services.
* refactor(control-plane): fix build errors and reduce more oversized functions
Fix type references in export.go and webhook.go, add missing fmt import,
and reduce additional oversized functions in validators and generators.
* refactor: reduce oversized functions in remaining services
Extract helpers from payment-order, position-keeping, reference-data,
party, and shared/platform packages.
* fix: resolve lint errors and additional oversized function reductions
- Fix gofmt formatting in 3 files
- Fix unused parameters (revive)
- Fix context-as-argument ordering (revive)
- Replace dynamic errors with sentinels (err113)
- Add nolint directives for intentional nil returns (nilerr, nilnil)
- Fix unchecked error returns (errcheck)
- Add nolint:contextcheck for false positives from helper extraction
- Remove stale nolint directives (nolintlint)
- Fix indent-error-flow (revive)
- Fix syntax error in api-gateway (func type)
- Fix type mismatch in api-gateway health init
- Additional function size reductions across services
Violations reduced from 284 to 196 (additional 88 eliminated).
* fix: resolve test failures and remaining lint issues
Test fixes (restore original behavior after helper extraction):
- payment-order: restore per-posting error message prefixes
- operational-gateway: add nil guard after route resolution failure
- position-keeping: propagate account validation errors properly
- tenant: preserve capitalized alert type names in log messages
- financial-accounting: use distinct error for idempotency re-check
- kafka: check context cancellation before DLQ on retry failure
Lint fixes:
- Add sentinel errors for dynamic error strings (err113)
- Fix context-as-argument parameter ordering (revive)
- Add missing switch case for StatusFailed (exhaustive)
- Fix defer-in-loop pattern (gocritic)
- Apply De Morgan's law and loop condition lift (staticcheck)
- Add nolint directives for intentional nil returns (nilnil)
- Fix nolint placement and gofmt formatting
* fix: resolve remaining lint issues
- Add nolint:nilnil for intentional nil,nil returns in payment-order
- Fix context-as-argument ordering in api-gateway auth handler
- Rename unused 'key' parameter to '_' in position-keeping migration
* fix: add nolint:nilnil for remaining intentional nil returns
* fix: restore review-critical behavioral regressions in refactored code
- Fix CancelFunc leak in buildFreshContext: return CancelFunc so callers
can defer cancel(), preventing distributed locks held until timeout expiry
- Restore per-flow RECONCILIATION_REQUIRED log fields lost during
capturePosting unification: debtor_account, contra_account,
clearing_account, and has_*_posting progress booleans needed for
incident response
- Fix LedgerEntryCount semantic change in reconciliation: use raw entry
count (pre-dedup) instead of deduplicated map length to match original
* fix: preallocate log field slices to satisfy prealloc lint
* chore: trigger re-review after thread resolution
* docs: clarify buildFreshContext godoc on why fresh context is needed
---------
Co-authored-by: Ben Coombs <bjcoombs@users.noreply.github.com>1 parent b441ed3 commit 6dc9591
210 files changed
Lines changed: 13800 additions & 11898 deletions
File tree
- services
- api-gateway
- cache
- cmd
- eventstream
- adapters
- internal/middleware
- audit-worker
- adapters
- kafka
- persistence
- cmd
- domain
- service
- control-plane
- cmd
- validate
- internal
- admin
- applier
- differ
- generator
- manifest
- staff
- stripe
- validator
- current-account/service
- event-router
- adapters
- mds
- messaging
- internal/handlers
- financial-accounting
- adapters
- messaging
- persistence
- client
- domain
- observability
- service
- worker
- financial-gateway
- adapters
- http
- stripe
- client
- forecasting
- adapters/persistence
- domain
- handler
- starlark
- validation
- identity
- adapters/persistence
- connector
- service
- internal-account
- adapters/persistence
- observability
- service
- market-information
- adapters
- external/ecb
- persistence
- testhelpers
- client
- cmd
- service
- mcp-server/internal
- auth
- tools
- operational-gateway
- adapters
- httpadapter
- persistence
- client
- cmd
- service
- worker
- party
- adapters
- http
- persistence
- service
- payment-order
- adapters
- gateway
- stripe
- http
- persistence
- app
- cmd
- domain/testfixtures
- service
- worker
- position-keeping
- adapters/persistence
- app
- client
- domain
- testfixtures
- service
- worker
- reconciliation
- adapters/stripe
- app
- client
- cmd
- service
- reference-data/saga
- tenant
- app
- notifier
- provisioner
- service
- worker
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
| 7 | + | |
6 | 8 | | |
7 | 9 | | |
| 10 | + | |
8 | 11 | | |
9 | 12 | | |
10 | 13 | | |
| |||
116 | 119 | | |
117 | 120 | | |
118 | 121 | | |
119 | | - | |
120 | | - | |
| 122 | + | |
| 123 | + | |
121 | 124 | | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
| 125 | + | |
128 | 126 | | |
129 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
130 | 146 | | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
| 147 | + | |
135 | 148 | | |
136 | 149 | | |
137 | | - | |
138 | 150 | | |
139 | | - | |
140 | | - | |
141 | 151 | | |
142 | 152 | | |
143 | 153 | | |
| |||
146 | 156 | | |
147 | 157 | | |
148 | 158 | | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
149 | 177 | | |
150 | | - | |
151 | | - | |
152 | | - | |
| 178 | + | |
153 | 179 | | |
154 | 180 | | |
155 | 181 | | |
156 | 182 | | |
157 | 183 | | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
167 | 188 | | |
168 | 189 | | |
169 | 190 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
50 | 53 | | |
51 | 54 | | |
52 | 55 | | |
| |||
200 | 203 | | |
201 | 204 | | |
202 | 205 | | |
203 | | - | |
204 | | - | |
| 206 | + | |
205 | 207 | | |
206 | | - | |
| 208 | + | |
207 | 209 | | |
208 | 210 | | |
209 | 211 | | |
210 | 212 | | |
211 | 213 | | |
212 | 214 | | |
213 | | - | |
| 215 | + | |
| 216 | + | |
214 | 217 | | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
215 | 234 | | |
216 | 235 | | |
217 | 236 | | |
| |||
224 | 243 | | |
225 | 244 | | |
226 | 245 | | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
| 246 | + | |
232 | 247 | | |
233 | 248 | | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
238 | 255 | | |
239 | 256 | | |
240 | 257 | | |
| |||
245 | 262 | | |
246 | 263 | | |
247 | 264 | | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
| 265 | + | |
256 | 266 | | |
257 | 267 | | |
258 | 268 | | |
| |||
298 | 308 | | |
299 | 309 | | |
300 | 310 | | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
| 311 | + | |
| 312 | + | |
356 | 313 | | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
| 314 | + | |
364 | 315 | | |
365 | 316 | | |
366 | 317 | | |
| |||
387 | 338 | | |
388 | 339 | | |
389 | 340 | | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
390 | 434 | | |
391 | 435 | | |
392 | 436 | | |
| |||
0 commit comments