Skip to content

Commit 1d057c9

Browse files
LuluBeatsonSamMorrowDrums
authored andcommitted
refactor: user get methods to avoid nil checks
1 parent 37d1ed6 commit 1d057c9

File tree

2 files changed

+9
-17
lines changed

2 files changed

+9
-17
lines changed

pkg/github/context_tools.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,10 @@ func GetMe(getClient GetClientFn, t translations.TranslationHelperFunc) (mcp.Too
4040

4141
// Create minimal user representation instead of returning full user object
4242
minimalUser := MinimalUser{
43-
Login: user.GetLogin(),
44-
ID: user.GetID(),
45-
}
46-
if user.HTMLURL != nil {
47-
minimalUser.ProfileURL = *user.HTMLURL
48-
}
49-
if user.AvatarURL != nil {
50-
minimalUser.AvatarURL = *user.AvatarURL
43+
Login: user.GetLogin(),
44+
ID: user.GetID(),
45+
ProfileURL: user.GetHTMLURL(),
46+
AvatarURL: user.GetAvatarURL(),
5147
}
5248

5349
return MarshalledTextResult(minimalUser), nil

pkg/github/search.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -224,15 +224,11 @@ func userOrOrgHandler(accountType string, getClient GetClientFn) server.ToolHand
224224

225225
for _, user := range result.Users {
226226
if user.Login != nil {
227-
mu := MinimalUser{Login: *user.Login}
228-
if user.ID != nil {
229-
mu.ID = *user.ID
230-
}
231-
if user.HTMLURL != nil {
232-
mu.ProfileURL = *user.HTMLURL
233-
}
234-
if user.AvatarURL != nil {
235-
mu.AvatarURL = *user.AvatarURL
227+
mu := MinimalUser{
228+
Login: user.GetLogin(),
229+
ID: user.GetID(),
230+
ProfileURL: user.GetHTMLURL(),
231+
AvatarURL: user.GetAvatarURL(),
236232
}
237233
minimalUsers = append(minimalUsers, mu)
238234
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy