Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix linting errors #414

Merged
merged 1 commit into from
Jun 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1302,18 +1302,19 @@ func waitForRunLock(t *testing.T, client *Client, workspaceID string) {
wg.Wait()
}

func retry(f retryableFn) (interface{}, error) {
func retry(f retryableFn) (interface{}, error) { //nolint
tick := time.NewTicker(tickDuration * time.Second)

retries := 0
maxRetries := 5

for {
defer tick.Stop()

for { //nolint
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed the two approaches for this block. The linter would have us simplify this block to iterate over the range of the ticker values, but we prefer to stick with the for / select option because it's consistent with how we use tickers in this library.

select {
case <-tick.C:
res, err := f()
if err == nil {
return res, err
return res, nil
}

if retries >= maxRetries {
Expand Down
4 changes: 2 additions & 2 deletions tfe.go
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ func checkResponseCode(r *http.Response) error {
return err
}

return fmt.Errorf(strings.Join(errs, "\n"))
return errors.New(strings.Join(errs, "\n"))
}

func decodeErrorPayload(r *http.Response) ([]string, error) {
Expand All @@ -863,7 +863,7 @@ func decodeErrorPayload(r *http.Response) ([]string, error) {
errPayload := &jsonapi.ErrorsPayload{}
err := json.NewDecoder(r.Body).Decode(errPayload)
if err != nil || len(errPayload.Errors) == 0 {
return errs, fmt.Errorf(r.Status)
return errs, errors.New(r.Status)
}

// Parse and format the errors.
Expand Down