Skip to content

refactor(go-oidc): flatten nested if in maskToken#29

Merged
appleboy merged 1 commit into
mainfrom
refactor/maskToken-flatten
May 23, 2026
Merged

refactor(go-oidc): flatten nested if in maskToken#29
appleboy merged 1 commit into
mainfrom
refactor/maskToken-flatten

Conversation

@appleboy
Copy link
Copy Markdown
Member

Summary

Flattens the nested if in maskToken (go-oidc example) into a top-to-bottom guard chain. Pure readability refactor — no behavior change: empty string → "", 1–8 chars → ****, longer → prefix....

AI Authorship

  • AI was used. Details:
    • Tool / model: Claude Opus 4.7 via Claude Code (code-simplifier agent)
    • AI-authored files: go-oidc/main.go
    • Human line-by-line reviewed: ⚠️ Not yet reviewed line-by-line by the author — reviewer should read the maskToken change closely.

Change classification

  • Leaf node (local impact) — maskToken is a small log-masking helper in a standalone example program; failure is local to that example.

Plan reference

No plan — this came out of a codebase-wide simplification pass. Goal: improve clarity without altering behavior.

Verification

  • Unit tests — none in this example module (no test files exist).
  • Build: go build ./... and go vet ./... pass in the go-oidc module.
  • Manual verification: confirm masking output for the three input classes — "", a short token (≤8 chars), and a long token (>8 chars).

Verifiability check

  • Inputs and outputs are documented (three input classes above)
  • Reviewer can judge correctness from the 6-line diff alone

Risk & rollback

  • Risk: Minimal — single helper, no signature or output change. Worst case is a masking edge case, contained to log output of one example.
  • Rollback: Revert the single commit 0a6f85d.

Reviewer guide

  • Read carefully: maskToken in go-oidc/main.go — verify the three branches still cover empty / short / long identically to before.
  • Spot-check OK: nothing else changed.

🤖 Generated with Claude Code

- Move the empty-string guard to the top of maskToken
- Read as a flat guard chain instead of nested conditionals
Copilot AI review requested due to automatic review settings May 23, 2026 11:25
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the maskToken helper in the go-oidc example by flattening a nested if into an early-return guard, keeping the masking behavior the same while improving readability.

Changes:

  • Refactored maskToken to return early for the empty-string case instead of checking it inside the len(s) <= 8 branch.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@appleboy appleboy merged commit f18620d into main May 23, 2026
8 checks passed
@appleboy appleboy deleted the refactor/maskToken-flatten branch May 23, 2026 11:44
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.

2 participants