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

Resources #9

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft

Resources #9

wants to merge 8 commits into from

Conversation

AlekSi
Copy link
Owner

@AlekSi AlekSi commented Aug 4, 2019

Closes #4.

@AlekSi AlekSi self-assigned this Aug 4, 2019
"net/http"
)

type Client struct {

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 {

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) {

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)

if err != nil {
return nil, err
}
defer resp.Body.Close()

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 {

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 {

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) {

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) {

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) {

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)

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 {

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 != "" {

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")

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") == "" {

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)

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 {

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())

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

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 == "" {

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

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)

@codecov
Copy link

codecov bot commented Dec 8, 2019

Codecov Report

Merging #9 into master will decrease coverage by 13.02%.
The diff coverage is 0%.

Impacted file tree graph

@@             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
Impacted Files Coverage Δ
resources/client.go 0% <0%> (ø)
handler.go 0% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9837c9b...80a26c2. Read the comment docs.

Base automatically changed from master to main January 16, 2021 07:37
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.

Add helpers for working with images
2 participants