refactor/webui: hoist duplicated route and header literals into constants #74

Merged
pti merged 1 commit from refactor/webui-literal-constants into main 2026-10-19 15:49:33 +02:00
Owner

Closes #66, part of the SonarQube cleanup in #73. Sonar rule go:S1192 flagged internal/webui/webui.go for the route string /rules repeated 28 times, /requests 12 times, the Content-Type header name and the text/html charset value 4 times each, and the message invalid rule index 5 times. This adds an unexported constant block near the top of webui.go and uses it at every site, including the mux.HandleFunc patterns, redirects and the safe-next fallback, so route registration and redirects share one spelling. api.go uses the header-name constant for its application/json header. Behaviour-neutral, no rendered output, status code or route changes. Templates are untouched, they are #68. One small table-driven test pins the five constant values since no existing test asserted the header value or the error text. All gates pass and the existing webui tests are unchanged. 🤖 Generated with Claude Code

Closes #66, part of the SonarQube cleanup in #73. Sonar rule go:S1192 flagged internal/webui/webui.go for the route string /rules repeated 28 times, /requests 12 times, the Content-Type header name and the text/html charset value 4 times each, and the message invalid rule index 5 times. This adds an unexported constant block near the top of webui.go and uses it at every site, including the mux.HandleFunc patterns, redirects and the safe-next fallback, so route registration and redirects share one spelling. api.go uses the header-name constant for its application/json header. Behaviour-neutral, no rendered output, status code or route changes. Templates are untouched, they are #68. One small table-driven test pins the five constant values since no existing test asserted the header value or the error text. All gates pass and the existing webui tests are unchanged. 🤖 Generated with Claude Code
refactor(webui): hoist duplicated route and header literals into constants
All checks were successful
Lint / lint (pull_request) Successful in 10m49s
Lint / sonarqube (pull_request) Has been skipped
13ea0c3333
Closes #66.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
pti merged commit 65d503008d into main 2026-10-19 15:49:33 +02:00
pti deleted branch refactor/webui-literal-constants 2026-10-19 15:49:33 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
pti/wraptool!74
No description provided.