Skip to content

Commit c917196

Browse files
committed
fix: lint
1 parent 5e4bbc4 commit c917196

8 files changed

Lines changed: 17 additions & 15 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515

1616
- updated github workflows to use the newest versions of the actions
1717
- removed unused code
18+
- fixed assorted lint errors
1819

1920
### Thanks
2021

api/httpClient.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@ func (c *client) NewRequest(method, uri string, body interface{}) (*http.Request
7676

7777
// Do executes a http.Request inside the Clockify's Client
7878
func (c *client) Do(
79-
req *http.Request, v interface{}, name string) (*http.Response, error) {
79+
req *http.Request, v interface{}, name string) (r *http.Response, err error) {
8080

8181
<-c.requestTickets
8282

83-
r, err := c.Client.Do(req)
83+
r, err = c.Client.Do(req)
8484
if err != nil {
8585
return r, err
8686
}
87-
defer r.Body.Close()
87+
defer func() { err = r.Body.Close() }()
8888

8989
buf := new(bytes.Buffer)
9090

cmd/clockify-cli/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ func execute() int {
7070
}
7171

7272
if f.Config().IsDebuging() {
73-
fmt.Fprintf(stderr, "%+v\n", err)
73+
_, _ = fmt.Fprintf(stderr, "%+v\n", err)
7474
} else {
75-
fmt.Fprintln(stderr, err.Error())
75+
_, _ = fmt.Fprintln(stderr, err.Error())
7676
}
7777

7878
return exitError

internal/consoletest/test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func RunTestConsole(
8989
if err != nil {
9090
t.Fatalf("failed to create console: %v", err)
9191
}
92-
defer c.Close()
92+
defer func() { _ = c.Close() }()
9393

9494
finished := false
9595
t.Cleanup(func() {
@@ -109,7 +109,7 @@ func RunTestConsole(
109109
}()
110110

111111
go func() {
112-
defer c.Tty().Close()
112+
defer func() { _ = c.Tty().Close() }()
113113
if err = setup(c.Tty(), c.Tty()); err != nil {
114114
t.Error(err)
115115
return

pkg/cmd/client/add/add.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"github.com/lucassabreu/clockify-cli/api/dto"
99
"github.com/lucassabreu/clockify-cli/pkg/cmd/client/util"
1010
"github.com/lucassabreu/clockify-cli/pkg/cmdutil"
11-
"github.com/lucassabreu/clockify-cli/pkg/output/client"
1211
"github.com/spf13/cobra"
1312
)
1413

@@ -66,10 +65,6 @@ func NewCmdAdd(
6665
return report(out, &of, cl)
6766
}
6867

69-
if of.JSON {
70-
client.ClientJSONPrint(cl, out)
71-
}
72-
7368
return util.Report([]dto.Client{cl}, out, of)
7469
},
7570
}

pkg/output/task/quiet.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import (
1010
// TaskPrintQuietly will only print the IDs
1111
func TaskPrintQuietly(ts []dto.Task, w io.Writer) error {
1212
for i := 0; i < len(ts); i++ {
13-
fmt.Fprintln(w, ts[i].ID)
13+
if _, err := fmt.Fprintln(w, ts[i].ID); err != nil {
14+
return err
15+
}
1416
}
1517

1618
return nil

pkg/output/user/quiet.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import (
1010
// UserPrintQuietly will only print the IDs
1111
func UserPrintQuietly(users []dto.User, w io.Writer) error {
1212
for i := 0; i < len(users); i++ {
13-
fmt.Fprintln(w, users[i].ID)
13+
if _, err := fmt.Fprintln(w, users[i].ID); err != nil {
14+
return err
15+
}
1416
}
1517

1618
return nil

pkg/output/workspace/quiet.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import (
1010
// WorkspacePrintQuietly will only print the IDs
1111
func WorkspacePrintQuietly(ws []dto.Workspace, w io.Writer) error {
1212
for i := 0; i < len(ws); i++ {
13-
fmt.Fprintln(w, ws[i].ID)
13+
if _, err := fmt.Fprintln(w, ws[i].ID); err != nil {
14+
return err
15+
}
1416
}
1517

1618
return nil

0 commit comments

Comments
 (0)