refactor: extract magic numbers to named constants #153

Merged
lerko merged 1 commits from refactor/magic-numbers-to-constants into main 2026-06-27 23:20:01 +00:00
Owner

Summary

  • Extract ~47 inline magic numbers to named constants across 15 files (14 modified, 1 new)
  • server: HTTP timeouts (read/write/idle), rate limits per endpoint, visitor cleanup intervals
  • cluster: follower timeout/retry/threshold, probe min/default interval, http.StatusOK replaces 200
  • store: DB pool sizes (open/idle/lifetime), token byte length
  • alert: HTTP client timeout
  • monitor: alert send timeout, dial timeout
  • tui: uptime thresholds (good/warn/excellent/precision), node online/stale thresholds, state history lookback/days/limit, HTTP error threshold, error detail max length — consolidated in new const.go

Not changed

  • TUI column widths / rendering dimensions (presentation, not domain logic)
  • Maintenance window durations in form (user-facing options, not magic numbers)
  • SLA period array (already structured data)
  • Port defaults in cmd/config.go (config defaults, self-documenting in context)

Test plan

  • go test ./... all green
  • golangci-lint run ./... 0 issues
  • No behavioral changes — pure rename refactor
## Summary - Extract ~47 inline magic numbers to named constants across 15 files (14 modified, 1 new) - **server**: HTTP timeouts (read/write/idle), rate limits per endpoint, visitor cleanup intervals - **cluster**: follower timeout/retry/threshold, probe min/default interval, `http.StatusOK` replaces `200` - **store**: DB pool sizes (open/idle/lifetime), token byte length - **alert**: HTTP client timeout - **monitor**: alert send timeout, dial timeout - **tui**: uptime thresholds (good/warn/excellent/precision), node online/stale thresholds, state history lookback/days/limit, HTTP error threshold, error detail max length — consolidated in new `const.go` ## Not changed - TUI column widths / rendering dimensions (presentation, not domain logic) - Maintenance window durations in form (user-facing options, not magic numbers) - SLA period array (already structured data) - Port defaults in cmd/config.go (config defaults, self-documenting in context) ## Test plan - [x] `go test ./...` all green - [x] `golangci-lint run ./...` 0 issues - [x] No behavioral changes — pure rename refactor
lerko added 1 commit 2026-06-27 19:44:19 +00:00
refactor: extract magic numbers to named constants
CI / test (pull_request) Successful in 1m43s
CI / lint (pull_request) Successful in 1m17s
CI / vulncheck (pull_request) Successful in 51s
50f77da131
Replace inline numeric literals with named constants across 14 files:
server timeouts/rate limits, cluster thresholds/intervals, DB pool
sizes, alert/dial timeouts, TUI uptime thresholds, node status
thresholds, and state history limits.
lerko merged commit 50f77da131 into main 2026-06-27 23:20:01 +00:00
lerko deleted branch refactor/magic-numbers-to-constants 2026-06-27 23:20:01 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: lerkolabs/uptop#153