Skip to content

Conversation

@tzzed
Copy link
Contributor

@tzzed tzzed commented May 5, 2022

No description provided.

Copy link
Member

@zarelit zarelit left a comment

Choose a reason for hiding this comment

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

Changes okay, error linting okay, there's one thing to change in the last changed line (see comment)

Comment on lines 816 to 825
if resp.StatusCode == http.StatusCreated {
return resp.Header.Get("Location"), false, nil
} else if resp.StatusCode == http.StatusNoContent {
}

if resp.StatusCode == http.StatusNoContent {
return resp.Header.Get("Location"), true, nil
} else {
bodyBytes, _ := ioutil.ReadAll(resp.Body)
return "", false, fmt.Errorf("Unexpected status code: '%d'\nResponse body: %s", resp.StatusCode, string(bodyBytes))
}
Copy link
Member

Choose a reason for hiding this comment

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

This is not an if statement used to return early because of error, and the most "special" case is the last one. So it's probably better to do one of the following:

  • make this whole block a switch/case statement
  • or remove both the else branches including the one before bodyBytes, _ :=
  • leave the if / else if / else

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants