From c8f3de248f89541ce410e480a9955d8e3348a5a8 Mon Sep 17 00:00:00 2001 From: Massaki Archambault Date: Thu, 8 Aug 2024 23:44:12 -0400 Subject: [PATCH] refactor to respect naming convention --- forges/github/client.go | 8 ++++---- forges/github/organization.go | 12 ++++++------ forges/github/user.go | 12 ++++++------ 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/forges/github/client.go b/forges/github/client.go index e7f1285..d7cc429 100644 --- a/forges/github/client.go +++ b/forges/github/client.go @@ -63,8 +63,8 @@ func (c *githubClient) FetchRootGroupContent() (map[string]fstree.GroupSource, e if c.rootContent == nil { rootContent := make(map[string]fstree.GroupSource) - for _, org_name := range c.GithubClientConfig.OrgNames { - org, err := c.fetchOrganization(org_name) + for _, orgName := range c.GithubClientConfig.OrgNames { + org, err := c.fetchOrganization(orgName) if err != nil { c.logger.Warn(err.Error()) } else { @@ -72,8 +72,8 @@ func (c *githubClient) FetchRootGroupContent() (map[string]fstree.GroupSource, e } } - for _, user_name := range c.GithubClientConfig.UserNames { - user, err := c.fetchUser(user_name) + for _, userName := range c.GithubClientConfig.UserNames { + user, err := c.fetchUser(userName) if err != nil { c.logger.Warn(err.Error()) } else { diff --git a/forges/github/organization.go b/forges/github/organization.go index 49520f9..a23569a 100644 --- a/forges/github/organization.go +++ b/forges/github/organization.go @@ -31,26 +31,26 @@ func (o *Organization) InvalidateContentCache() { o.childRepositories = nil } -func (c *githubClient) fetchOrganization(org_name string) (*Organization, error) { +func (c *githubClient) fetchOrganization(orgName string) (*Organization, error) { c.organizationCacheMux.RLock() - cachedId, found := c.organizationNameToIDMap[org_name] + cachedId, found := c.organizationNameToIDMap[orgName] if found { cachedOrg := c.organizationCache[cachedId] c.organizationCacheMux.RUnlock() // if found in cache, return the cached reference - c.logger.Debug("Organization cache hit", "org_name", org_name) + c.logger.Debug("Organization cache hit", "org_name", orgName) return cachedOrg, nil } else { c.organizationCacheMux.RUnlock() - c.logger.Debug("Organization cache miss", "org_name", org_name) + c.logger.Debug("Organization cache miss", "org_name", orgName) } // If not found in cache, fetch organization infos from API - githubOrg, _, err := c.client.Organizations.Get(context.Background(), org_name) + githubOrg, _, err := c.client.Organizations.Get(context.Background(), orgName) if err != nil { - return nil, fmt.Errorf("failed to fetch organization with name %v: %v", org_name, err) + return nil, fmt.Errorf("failed to fetch organization with name %v: %v", orgName, err) } newOrg := Organization{ ID: *githubOrg.ID, diff --git a/forges/github/user.go b/forges/github/user.go index a2ed503..55c294a 100644 --- a/forges/github/user.go +++ b/forges/github/user.go @@ -31,26 +31,26 @@ func (u *User) InvalidateContentCache() { u.childRepositories = nil } -func (c *githubClient) fetchUser(user_name string) (*User, error) { +func (c *githubClient) fetchUser(userName string) (*User, error) { c.userCacheMux.RLock() - cachedId, found := c.userNameToIDMap[user_name] + cachedId, found := c.userNameToIDMap[userName] if found { cachedUser := c.userCache[cachedId] c.userCacheMux.RUnlock() // if found in cache, return the cached reference - c.logger.Debug("User cache hit", "user_name", user_name) + c.logger.Debug("User cache hit", "user_name", userName) return cachedUser, nil } else { c.userCacheMux.RUnlock() - c.logger.Debug("User cache miss", "user_name", user_name) + c.logger.Debug("User cache miss", "user_name", userName) } // If not found in cache, fetch user infos from API - githubUser, _, err := c.client.Users.Get(context.Background(), user_name) + githubUser, _, err := c.client.Users.Get(context.Background(), userName) if err != nil { - return nil, fmt.Errorf("failed to fetch user with name %v: %v", user_name, err) + return nil, fmt.Errorf("failed to fetch user with name %v: %v", userName, err) } newUser := User{ ID: *githubUser.ID,