Skip to content

Refactor: remove dead code and deduplicate httpserver helpers#49

Merged
eswan18 merged 1 commit into
mainfrom
refactor/code-smells
Mar 30, 2026
Merged

Refactor: remove dead code and deduplicate httpserver helpers#49
eswan18 merged 1 commit into
mainfrom
refactor/code-smells

Conversation

@eswan18

@eswan18 eswan18 commented Mar 30, 2026

Copy link
Copy Markdown
Owner

Summary

  • Remove stale internal/db package (unused sqlc output with outdated schema — 589 lines of dead code)
  • Consolidate duplicated validateCredentials / validateCredentialsIncludingInactive into a shared doValidateCredentials with a function parameter for the DB query
  • Consolidate duplicated getUserFromSession / getUserFromSessionIncludingInactive into a shared doGetUserFromSession with a function parameter
  • Extract duplicated OAuth client authentication (get client, verify secret) into authenticateClient, used by token, refresh, introspect, and revoke handlers
  • Consolidate four identical JSON error response writers (writeTokenError, writeIntrospectError, writeRevokeError, writeAdminError) into a shared writeJSONError function
  • Consolidate duplicated CORS middleware (corsMiddleware, oauthCorsMiddleware) into a parameterized newCorsMiddleware factory
  • Replace manual URL concatenation in HandleRegisterPost with url.Values (resolves existing TODO)

Net change: -678 lines (103 added, 781 removed)

Test plan

  • go build ./... passes
  • go vet ./... passes
  • All unit tests pass (go test ./... — integration tests require Docker, unrelated to this change)
  • Verify OAuth flows work in staging after deploy

🤖 Generated with Claude Code

- Remove stale internal/db package (unused sqlc output with outdated schema)
- Consolidate duplicated validateCredentials / validateCredentialsIncludingInactive
  into shared doValidateCredentials with a function parameter
- Consolidate duplicated getUserFromSession / getUserFromSessionIncludingInactive
  into shared doGetUserFromSession with a function parameter
- Extract duplicated OAuth client authentication into authenticateClient,
  used by token, refresh, introspect, and revoke handlers
- Consolidate four identical JSON error writers (writeTokenError, writeIntrospectError,
  writeRevokeError, writeAdminError) into shared writeJSONError
- Consolidate duplicated CORS middleware into parameterized newCorsMiddleware factory
- Replace manual URL string concatenation in HandleRegisterPost with url.Values
  (resolves existing TODO)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@eswan18 eswan18 merged commit 82c080a into main Mar 30, 2026
1 check passed
@eswan18 eswan18 deleted the refactor/code-smells branch March 30, 2026 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant