Skip to content

Resources - #9

Draft
AlekSi wants to merge 8 commits into
mainfrom
resources
Draft

AlekSi wants to merge 8 commits into
mainfrom
resources

Conversation

@AlekSi

@AlekSi AlekSi commented Aug 4, 2019

Copy link
Copy Markdown
Owner

Closes #4.

@AlekSi AlekSi self-assigned this Aug 4, 2019
Comment thread resources/client.go
"net/http"
)

type Client struct {

Copy link
Copy Markdown

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)

Comment thread resources/client.go
return http.DefaultClient
}

type StatusResponse struct {

Copy link
Copy Markdown

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)

Comment thread resources/client.go
Used int
}

func (c *Client) Status() (*StatusResponse, error) {

Copy link
Copy Markdown

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)

Comment thread resources/client.go Outdated
if err != nil {
return nil, err
}
defer resp.Body.Close()

Copy link
Copy Markdown

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)

Comment thread resources/client.go
"github.com/AlekSi/alice"
)

type Quota struct {

Copy link
Copy Markdown

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)

Comment thread resources/client.go
Used int
}

type Sound struct {

Copy link
Copy Markdown

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)

Comment thread resources/client.go
return &res, nil
}

func (c *Client) UploadSound(name string, r io.Reader) (*Sound, error) {

Copy link
Copy Markdown

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)

Comment thread resources/client.go
return &res.Sound, nil
}

func (c *Client) UploadSoundFile(filename string) (*Sound, error) {

Copy link
Copy Markdown

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)

Comment thread resources/client.go
return c.UploadSound(filepath.Base(filename), f)
}

func (c *Client) ListSounds() ([]Sound, error) {

Copy link
Copy Markdown

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)

Comment thread resources/client.go
}

func (c *Client) UploadSoundFile(filename string) (*Sound, error) {
f, err := os.Open(filename)

Copy link
Copy Markdown

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)

Comment thread resources/client.go
StrictDecoder bool // disallow unexpected fields in responses
}

func (c *Client) do(req *http.Request, respBody interface{}) error {

Copy link
Copy Markdown

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)

Comment thread resources/client.go
}

var jsonRequst bool
if c.OAuthToken != "" {

Copy link
Copy Markdown

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)

Comment thread resources/client.go
}
if req.Body != nil && req.Header.Get("Content-Type") == "" {
jsonRequst = true
req.Header.Set("Content-Type", "application/json; charset=utf-8")

Copy link
Copy Markdown

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)

Comment thread resources/client.go
if c.OAuthToken != "" {
req.Header.Set("Authorization", "OAuth "+c.OAuthToken)
}
if req.Body != nil && req.Header.Get("Content-Type") == "" {

Copy link
Copy Markdown

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)

Comment thread resources/client.go
if err = json.Indent(&body, b, "", " "); err != nil {
return err
}
req.Body = ioutil.NopCloser(&body)

Copy link
Copy Markdown

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)

Comment thread resources/client.go
if _, err = io.Copy(fw, r); err != nil {
return nil, err
}
if err = mw.Close(); err != nil {

Copy link
Copy Markdown

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)

Comment thread resources/client.go
if err != nil {
return nil, err
}
req.Header.Add("Content-Type", mw.FormDataContentType())

Copy link
Copy Markdown

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)

Comment thread resources/client.go
if err = c.do(req, &res); err != nil {
return nil, err
}
return &res.Sound, nil

Copy link
Copy Markdown

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)

Comment thread resources/client_test.go

skillID := os.Getenv("ALICE_TEST_SKILL_ID")
oAuthToken := os.Getenv("ALICE_TEST_OAUTH_TOKEN")
if skillID == "" || oAuthToken == "" {

Copy link
Copy Markdown

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)

Comment thread resources/client.go
@@ -0,0 +1,204 @@
package resources

Copy link
Copy Markdown

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

codecov Bot commented Dec 8, 2019

Copy link
Copy Markdown

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