-
Notifications
You must be signed in to change notification settings - Fork 1
Closed
Labels
Description
Summary
The auth/auth.go file contains two inline HTML templates (errorPageTemplate and successPageTemplate) totaling 88 lines of CSS/HTML string literals. These represent 15% of the file and obscure the Go logic. Moving them to embedded files using //go:embed would improve readability and maintainability. Additionally, the Google userinfo URL is a hardcoded magic string.
Location
- File:
internal/auth/auth.go - HTML templates: L55-95 (
errorPageTemplate), L97-143 (successPageTemplate) - Magic URL: L202 (
"https://www.googleapis.com/oauth2/v2/userinfo")
Category
Type: Magic Strings / Code Organization
Severity: Low
Evidence
88 lines of inline HTML/CSS:
var errorPageTemplate = `<!DOCTYPE html>
<html><head>
<style>
body { font-family: -apple-system, ...; }
...
</style>
</head><body>
...
</body></html>`Hardcoded URL:
resp, err := client.Get("https://www.googleapis.com/oauth2/v2/userinfo")Suggested Refactoring
- Create
internal/auth/templates/directory witherror.htmlandsuccess.html - Use
//go:embed templates/error.htmlto load at compile time - Extract
const googleUserInfoURL = "https://www.googleapis.com/oauth2/v2/userinfo" - Consider using
html/templatefor the success page's dynamic account list
Effort Estimate
- Size: Small (< 1 hour)
- Risk: Low (cosmetic change, same behavior)
- Tests Required: No (manual OAuth flow test recommended)
Acceptance Criteria
- HTML templates moved to embedded files
- Userinfo URL extracted to named constant
-
auth.goreduced by ~88 lines - OAuth flow still works correctly
-
go build ./...passes
Reactions are currently unavailable