Skip to content

Commit

Permalink
fix usestdlibvars linter
Browse files Browse the repository at this point in the history
Signed-off-by: Spencer Schrock <[email protected]>
  • Loading branch information
spencerschrock committed Oct 18, 2023
1 parent ddd89d3 commit fc00722
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 11 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ linters:
- typecheck
- unconvert
- unused
- usestdlibvars
- whitespace
- wrapcheck
linters-settings:
Expand Down
2 changes: 1 addition & 1 deletion clients/cii_http_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (transport *expBackoffTransport) RoundTrip(req *http.Request) (*http.Respon
func (client *httpClientCIIBestPractices) GetBadgeLevel(ctx context.Context, uri string) (BadgeLevel, error) {
repoURI := fmt.Sprintf("https://%s", uri)
url := fmt.Sprintf("https://www.bestpractices.dev/projects.json?url=%s", repoURI)
req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
if err != nil {
return Unknown, fmt.Errorf("error during http.NewRequestWithContext: %w", err)
}
Expand Down
5 changes: 3 additions & 2 deletions clients/gitlabrepo/branches.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package gitlabrepo

import (
"fmt"
"net/http"
"strings"
"sync"

Expand Down Expand Up @@ -84,10 +85,10 @@ func (handler *branchesHandler) setup() error {
if branch.Protected {
protectedBranch, resp, err := handler.getProtectedBranch(
handler.repourl.projectID, branch.Name)
if err != nil && resp.StatusCode != 403 {
if err != nil && resp.StatusCode != http.StatusForbidden {
handler.errSetup = fmt.Errorf("request for protected branch failed with error %w", err)
return
} else if resp.StatusCode == 403 {
} else if resp.StatusCode == http.StatusForbidden {
handler.errSetup = fmt.Errorf("incorrect permissions to fully check branch protection %w", err)
return
}
Expand Down
4 changes: 2 additions & 2 deletions clients/gitlabrepo/branches_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestGetBranches(t *testing.T) {
},
returnStatus: &gitlab.Response{
Response: &http.Response{
StatusCode: 200,
StatusCode: http.StatusOK,
},
},
branchReturn: &gitlab.ProtectedBranch{},
Expand All @@ -69,7 +69,7 @@ func TestGetBranches(t *testing.T) {
},
returnStatus: &gitlab.Response{
Response: &http.Response{
StatusCode: 200,
StatusCode: http.StatusOK,
},
},
},
Expand Down
3 changes: 2 additions & 1 deletion clients/gitlabrepo/issues.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package gitlabrepo

import (
"fmt"
"net/http"
"sync"

"github.com/xanzy/go-gitlab"
Expand Down Expand Up @@ -53,7 +54,7 @@ func (handler *issuesHandler) setup() error {
if err != nil && resp.StatusCode != 401 {
handler.errSetup = fmt.Errorf("unable to find access tokens associated with the project id: %w", err)
return
} else if resp.StatusCode == 401 {
} else if resp.StatusCode == http.StatusUnauthorized {
handler.errSetup = fmt.Errorf("insufficient permissions to check issue author associations %w", err)
return
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/internal/nuget/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ func testResult(wantErr bool, responseFileName string) (*http.Response, error) {
}
if wantErr && responseFileName == "text" {
return &http.Response{
StatusCode: 200,
StatusCode: http.StatusOK,
Body: io.NopCloser(bytes.NewBufferString("text")),
}, nil
}
Expand All @@ -617,7 +617,7 @@ func testResult(wantErr bool, responseFileName string) (*http.Response, error) {
return nil, fmt.Errorf("%w", err)
}
return &http.Response{
StatusCode: 200,
StatusCode: http.StatusOK,
Body: io.NopCloser(bytes.NewBufferString(string(content))),
}, nil
}
6 changes: 3 additions & 3 deletions cmd/package_managers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func Test_fetchGitRepositoryFromNPM(t *testing.T) {
}

return &http.Response{
StatusCode: 200,
StatusCode: http.StatusOK,
Body: io.NopCloser(bytes.NewBufferString(tt.args.result)),
}, nil
}).AnyTimes()
Expand Down Expand Up @@ -456,7 +456,7 @@ func Test_fetchGitRepositoryFromPYPI(t *testing.T) {
}

return &http.Response{
StatusCode: 200,
StatusCode: http.StatusOK,
Body: io.NopCloser(bytes.NewBufferString(tt.args.result)),
}, nil
}).AnyTimes()
Expand Down Expand Up @@ -725,7 +725,7 @@ func Test_fetchGitRepositoryFromRubyGems(t *testing.T) {
}

return &http.Response{
StatusCode: 200,
StatusCode: http.StatusOK,
Body: io.NopCloser(bytes.NewBufferString(tt.args.result)),
}, nil
}).AnyTimes()
Expand Down

0 comments on commit fc00722

Please sign in to comment.