Conversation
| "net/http" | ||
| ) | ||
|
|
||
| type Client struct { |
There was a problem hiding this comment.
exported type Client should have comment or be unexported (from golint)
| return http.DefaultClient | ||
| } | ||
|
|
||
| type StatusResponse struct { |
There was a problem hiding this comment.
exported type StatusResponse should have comment or be unexported (from golint)
| Used int | ||
| } | ||
|
|
||
| func (c *Client) Status() (*StatusResponse, error) { |
There was a problem hiding this comment.
exported method Client.Status should have comment or be unexported (from golint)
resources/client.go
Outdated
| if err != nil { | ||
| return nil, err | ||
| } | ||
| defer resp.Body.Close() |
There was a problem hiding this comment.
Error return value of resp.Body.Close is not checked (from errcheck)
| "github.com/AlekSi/alice" | ||
| ) | ||
|
|
||
| type Quota struct { |
There was a problem hiding this comment.
exported type Quota should have comment or be unexported (from golint)
| Used int | ||
| } | ||
|
|
||
| type Sound struct { |
There was a problem hiding this comment.
exported type Sound should have comment or be unexported (from golint)
| return &res, nil | ||
| } | ||
|
|
||
| func (c *Client) UploadSound(name string, r io.Reader) (*Sound, error) { |
There was a problem hiding this comment.
exported method Client.UploadSound should have comment or be unexported (from golint)
| return &res.Sound, nil | ||
| } | ||
|
|
||
| func (c *Client) UploadSoundFile(filename string) (*Sound, error) { |
There was a problem hiding this comment.
exported method Client.UploadSoundFile should have comment or be unexported (from golint)
| return c.UploadSound(filepath.Base(filename), f) | ||
| } | ||
|
|
||
| func (c *Client) ListSounds() ([]Sound, error) { |
There was a problem hiding this comment.
exported method Client.ListSounds should have comment or be unexported (from golint)
| } | ||
|
|
||
| func (c *Client) UploadSoundFile(filename string) (*Sound, error) { | ||
| f, err := os.Open(filename) |
There was a problem hiding this comment.
G304: Potential file inclusion via variable (from gosec)
| StrictDecoder bool // disallow unexpected fields in responses | ||
| } | ||
|
|
||
| func (c *Client) do(req *http.Request, respBody interface{}) error { |
There was a problem hiding this comment.
cognitive complexity 32 of func (*Client).do is high (> 30) (from gocognit)
| } | ||
|
|
||
| var jsonRequst bool | ||
| if c.OAuthToken != "" { |
There was a problem hiding this comment.
if statements should only be cuddled with assignments used in the if statement itself (from wsl)
| } | ||
| if req.Body != nil && req.Header.Get("Content-Type") == "" { | ||
| jsonRequst = true | ||
| req.Header.Set("Content-Type", "application/json; charset=utf-8") |
There was a problem hiding this comment.
only cuddled expressions if assigning variable or using from line above (from wsl)
| if c.OAuthToken != "" { | ||
| req.Header.Set("Authorization", "OAuth "+c.OAuthToken) | ||
| } | ||
| if req.Body != nil && req.Header.Get("Content-Type") == "" { |
There was a problem hiding this comment.
if statements should only be cuddled with assignments (from wsl)
| if err = json.Indent(&body, b, "", " "); err != nil { | ||
| return err | ||
| } | ||
| req.Body = ioutil.NopCloser(&body) |
There was a problem hiding this comment.
assignments should only be cuddled with other assignments (from wsl)
| if _, err = io.Copy(fw, r); err != nil { | ||
| return nil, err | ||
| } | ||
| if err = mw.Close(); err != nil { |
There was a problem hiding this comment.
if statements should only be cuddled with assignments (from wsl)
| if err != nil { | ||
| return nil, err | ||
| } | ||
| req.Header.Add("Content-Type", mw.FormDataContentType()) |
There was a problem hiding this comment.
expressions should not be cuddled with blocks (from wsl)
| if err = c.do(req, &res); err != nil { | ||
| return nil, err | ||
| } | ||
| return &res.Sound, nil |
There was a problem hiding this comment.
return statements should not be cuddled if block has more than two lines (from wsl)
|
|
||
| skillID := os.Getenv("ALICE_TEST_SKILL_ID") | ||
| oAuthToken := os.Getenv("ALICE_TEST_OAUTH_TOKEN") | ||
| if skillID == "" || oAuthToken == "" { |
There was a problem hiding this comment.
only one cuddle assignment allowed before if statement (from wsl)
| @@ -0,0 +1,204 @@ | |||
| package resources | |||
There was a problem hiding this comment.
ST1000: at least one file in a package should have a package comment (from stylecheck)
# Conflicts: # .gitignore
Codecov Report
@@ Coverage Diff @@
## master #9 +/- ##
===========================================
- Coverage 32.44% 19.42% -13.03%
===========================================
Files 4 5 +1
Lines 188 314 +126
===========================================
Hits 61 61
- Misses 120 246 +126
Partials 7 7
Continue to review full report at Codecov.
|
Closes #4.