-
Notifications
You must be signed in to change notification settings - Fork 0
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
Resources #9
base: main
Are you sure you want to change the base?
Conversation
"net/http" | ||
) | ||
|
||
type Client struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exported type Client
should have comment or be unexported (from golint
)
return http.DefaultClient | ||
} | ||
|
||
type StatusResponse struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exported type Quota
should have comment or be unexported (from golint
)
Used int | ||
} | ||
|
||
type Sound struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only one cuddle assignment allowed before if statement (from wsl
)
@@ -0,0 +1,204 @@ | |||
package resources |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.