refactor(github): address review findings from round 2872
PR Ready Gate / clear-labels (pull_request) Successful in 2s
CI / test (pull_request) Successful in 17s
CI / review (anthropic--claude-4.6-sonnet, sonnet, SONNET_REVIEW_TOKEN) (pull_request) Successful in 36s
CI / review (gpt-5, gpt, GPT_REVIEW_TOKEN) (pull_request) Successful in 1m31s
CI / review (gpt-5, security, ., rodin/security-patterns, SECURITY_REVIEW.md, SECURITY_REVIEW_TOKEN) (pull_request) Successful in 1m53s
PR Ready Gate / clear-labels (pull_request) Successful in 2s
CI / test (pull_request) Successful in 17s
CI / review (anthropic--claude-4.6-sonnet, sonnet, SONNET_REVIEW_TOKEN) (pull_request) Successful in 36s
CI / review (gpt-5, gpt, GPT_REVIEW_TOKEN) (pull_request) Successful in 1m31s
CI / review (gpt-5, security, ., rodin/security-patterns, SECURITY_REVIEW.md, SECURITY_REVIEW_TOKEN) (pull_request) Successful in 1m53s
- client.go: clarify timer drain comment (finding #1) - client.go: rename t -> retryAt for time.Time clarity (finding #2) - pr.go: remove dead _ string parameter from mapCheckRunStatus (finding #3) - files.go: add inline comment explaining zero-value guard (finding #4) Findings #5 (NIT, no code change) and #6 (NIT, defer vs t.Cleanup in t.Run closures) pushed back — see PR comment.
This commit is contained in:
+3
-3
@@ -199,7 +199,7 @@ func (c *Client) doRequest(ctx context.Context, method, reqURL string, accept st
|
|||||||
timer := time.NewTimer(delay)
|
timer := time.NewTimer(delay)
|
||||||
select {
|
select {
|
||||||
case <-timer.C:
|
case <-timer.C:
|
||||||
// Timer already fired; Stop() is a no-op here.
|
// Backoff elapsed, proceed with retry.
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
timer.Stop()
|
timer.Stop()
|
||||||
return nil, ctx.Err()
|
return nil, ctx.Err()
|
||||||
@@ -259,8 +259,8 @@ func (c *Client) doRequest(ctx context.Context, method, reqURL string, accept st
|
|||||||
if attempt < len(backoff) {
|
if attempt < len(backoff) {
|
||||||
backoff[attempt] = delay
|
backoff[attempt] = delay
|
||||||
}
|
}
|
||||||
} else if t, err := http.ParseTime(ra); err == nil {
|
} else if retryAt, err := http.ParseTime(ra); err == nil {
|
||||||
delay := time.Until(t)
|
delay := time.Until(retryAt)
|
||||||
if delay < 0 {
|
if delay < 0 {
|
||||||
delay = 0
|
delay = 0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ func (c *Client) ListContents(ctx context.Context, owner, repo, path string) ([]
|
|||||||
if err2 := json.Unmarshal(body, &single); err2 != nil {
|
if err2 := json.Unmarshal(body, &single); err2 != nil {
|
||||||
return nil, fmt.Errorf("parse contents JSON: %w", err2)
|
return nil, fmt.Errorf("parse contents JSON: %w", err2)
|
||||||
}
|
}
|
||||||
|
// Guard against empty objects ({}) or unexpected shapes that
|
||||||
|
// unmarshal successfully but carry no useful data.
|
||||||
if single.Name == "" && single.Path == "" && single.Type == "" {
|
if single.Name == "" && single.Path == "" && single.Type == "" {
|
||||||
return nil, fmt.Errorf("parse contents JSON: unexpected response format")
|
return nil, fmt.Errorf("parse contents JSON: unexpected response format")
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-5
@@ -194,7 +194,7 @@ func (c *Client) GetCommitStatuses(ctx context.Context, owner, repo, sha string)
|
|||||||
for _, cr := range checkResp.CheckRuns {
|
for _, cr := range checkResp.CheckRuns {
|
||||||
result = append(result, vcs.CommitStatus{
|
result = append(result, vcs.CommitStatus{
|
||||||
Context: cr.Name,
|
Context: cr.Name,
|
||||||
Status: mapCheckRunStatus(cr.Conclusion, cr.Status),
|
Status: mapCheckRunStatus(cr.Conclusion),
|
||||||
Description: derefString(cr.Conclusion),
|
Description: derefString(cr.Conclusion),
|
||||||
TargetURL: cr.HTMLURL,
|
TargetURL: cr.HTMLURL,
|
||||||
})
|
})
|
||||||
@@ -208,10 +208,9 @@ func (c *Client) GetCommitStatuses(ctx context.Context, owner, repo, sha string)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// mapCheckRunStatus maps a check run conclusion to a vcs.CommitStatus status string.
|
// mapCheckRunStatus maps a check run conclusion to a vcs.CommitStatus status string.
|
||||||
// The second parameter (check run status field, e.g. "completed", "in_progress") is
|
// Conclusion alone determines the mapped state: nil conclusion means the run is
|
||||||
// unused because conclusion alone determines the mapped state: nil conclusion means
|
// still in progress (pending), regardless of the status field value.
|
||||||
// the run is still in progress (pending), regardless of the status field value.
|
func mapCheckRunStatus(conclusion *string) string {
|
||||||
func mapCheckRunStatus(conclusion *string, _ string) string {
|
|
||||||
if conclusion == nil {
|
if conclusion == nil {
|
||||||
// Still running or queued
|
// Still running or queued
|
||||||
return "pending"
|
return "pending"
|
||||||
|
|||||||
Reference in New Issue
Block a user