Skip to content

Commit

Permalink
chore: rewrite to use standard lib constants when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
ccoVeille committed Jul 3, 2024
1 parent ca6dcfc commit 56538e3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ linters:
- typecheck
- unparam
- unused
- usestdlibvars
- varcheck

linters-settings:
Expand Down
8 changes: 4 additions & 4 deletions pkg/mdformatter/linktransformer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,14 @@ func getGitHubRegex(pullsIssuesRe string, repoToken string) (*regexp.Regexp, int
client := &http.Client{}

// Check latest pull request number.
reqPull, err := http.NewRequest("GET", fmt.Sprintf(gitHubAPIURL, reponame, "pulls"), nil)
reqPull, err := http.NewRequest(http.MethodGet, fmt.Sprintf(gitHubAPIURL, reponame, "pulls"), nil)
if err != nil {
return nil, math.MaxInt64, err
}
reqPull.Header.Set("User-Agent", "mdox")

// Check latest issue number and return whichever is greater.
reqIssue, err := http.NewRequest("GET", fmt.Sprintf(gitHubAPIURL, reponame, "issues"), nil)
reqIssue, err := http.NewRequest(http.MethodGet, fmt.Sprintf(gitHubAPIURL, reponame, "issues"), nil)
if err != nil {
return nil, math.MaxInt64, err
}
Expand All @@ -170,7 +170,7 @@ func getGitHubRegex(pullsIssuesRe string, repoToken string) (*regexp.Regexp, int
if err != nil {
return nil, math.MaxInt64, err
}
if respPull.StatusCode != 200 {
if respPull.StatusCode != http.StatusOK {
return nil, math.MaxInt64, fmt.Errorf("pulls API request failed. status code: %d", respPull.StatusCode)
}
defer respPull.Body.Close()
Expand All @@ -182,7 +182,7 @@ func getGitHubRegex(pullsIssuesRe string, repoToken string) (*regexp.Regexp, int
if err != nil {
return nil, math.MaxInt64, err
}
if respIssue.StatusCode != 200 {
if respIssue.StatusCode != http.StatusOK {
return nil, math.MaxInt64, fmt.Errorf("issues API request failed. status code: %d", respIssue.StatusCode)
}
defer respIssue.Body.Close()
Expand Down

0 comments on commit 56538e3

Please sign in to comment.