refactor: simplify handlers and user service#200
Merged
Conversation
- Compute the device verification user code once instead of formatting it twice - Drop the unused revoked-token count variable in the client revoke handler - Hoist the static OIDC discovery subject and claims lists to package scope to avoid per-request allocation - Flatten nested email and uniqueness checks into guard clauses Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR performs a small refactor pass across handlers and the user service to reduce redundant work, remove dead code, and simplify conditional logic, while keeping behavior and API responses unchanged.
Changes:
- Deduplicates device-flow
user_codeformatting and removes an unused revoke-all return value. - Hoists static OIDC discovery lists to package scope to avoid per-request slice allocations.
- Flattens user uniqueness checks into guard clauses in
UserService.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal/services/user.go | Simplifies email/username uniqueness checks and removes unnecessary local shadowing. |
| internal/handlers/oidc.go | Moves static discovery subject_types_supported / claims_supported slices to package scope and reuses them in responses. |
| internal/handlers/device.go | Computes formatted device verification user_code once and reuses it in the response payload. |
| internal/handlers/client.go | Drops unused revokedCount from revoke-all handler call site. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Pure code-quality cleanup from a
/simplifypass over the handlers and user service. No behavior changes — eliminates redundant work, dead code, and nested conditionals flagged against the project's "no if/else chains" convention.AI Authorship
/simplifyskill)internal/handlers/client.go,internal/handlers/device.go,internal/handlers/oidc.go,internal/services/user.goChange classification
internal/services/user.gotouches user uniqueness logic (core-adjacent). See reviewer guide.Verification
make generate→go build ./...cleango vet ./...cleaninternal/handlers,internal/services,internal/util,internal/tokenVerifiability check
Risk & rollback
Reviewer guide
internal/services/user.go— confirm the flattened email/username guard clauses are logically equivalent to the priorif/else if(no inverted conditions,errreuse is correct).oidc.go(verbatim slice hoist),device.go(dedup of one call),client.go(dead-var removal).🤖 Generated with Claude Code