From 8bc33cf2b747cbd30e6ec0a6f55ff344ebca7479 Mon Sep 17 00:00:00 2001 From: Lucas dos Santos Abreu Date: Thu, 26 Mar 2026 09:12:14 -0300 Subject: [PATCH 1/8] chore: update workflows versions & fix mistakes --- .github/workflows/golangci-lint.yml | 7 +++---- .github/workflows/release.yml | 6 +++--- .github/workflows/test-unit.yaml | 8 ++++---- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 78e28c5b..bedf24b7 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -16,12 +16,11 @@ jobs: name: lint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 + - uses: actions/checkout@v6 + - uses: actions/setup-go@v6 with: go-version: 1.24 - cache: false - name: golangci-lint - uses: golangci/golangci-lint-action@v7 + uses: golangci/golangci-lint-action@v9 with: version: latest diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2f7bd418..0eca37f0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,13 +11,13 @@ jobs: runs-on: ubuntu-latest steps: - name: checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: go-setup - uses: actions/setup-go@v5 + uses: actions/setup-go@v6 with: go-version: 1.24 - name: install snapcraft - uses: samuelmeuli/action-snapcraft@v4 + uses: samuelmeuli/action-snapcraft@v3 - name: install nix uses: cachix/install-nix-action@v31 - name: goreleaser-setup diff --git a/.github/workflows/test-unit.yaml b/.github/workflows/test-unit.yaml index 298eed7f..ef63a3be 100644 --- a/.github/workflows/test-unit.yaml +++ b/.github/workflows/test-unit.yaml @@ -8,9 +8,9 @@ jobs: steps: - name: Check out code into the Go module directory - uses: actions/checkout@v4 + uses: actions/checkout@v6 - - uses: actions/setup-go@v5 + - uses: actions/setup-go@v6 with: go-version: 1.24 @@ -30,11 +30,11 @@ jobs: uses: codecov/codecov-action@v5 with: token: ${{ secrets.CODECOV_TOKEN }} - file: ./coverage.txt + files: ./coverage.txt flags: unittests - name: Report test coverage to DeepSource - uses: deepsourcelabs/test-coverage-action@v1 + uses: deepsourcelabs/test-coverage-action@master with: key: go coverage-file: ./coverage.txt From a43198710a24c3bac0ed68b4f68a3914fbea043a Mon Sep 17 00:00:00 2001 From: Lucas dos Santos Abreu Date: Thu, 26 Mar 2026 09:12:21 -0300 Subject: [PATCH 2/8] fix: build also clean --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9bb2c368..1bf11f99 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ deps-upgrade: ## upgrade go dependencies go get -u -v $(MAIN_PKG) go mod tidy -build: dist +build: clean dist dist: deps-install dist/darwin dist/linux dist/windows ## build all cli versions (default) From 5e4bbc4c659f60948596c723971c52c5b8b8c296 Mon Sep 17 00:00:00 2001 From: Lucas dos Santos Abreu Date: Thu, 26 Mar 2026 09:15:15 -0300 Subject: [PATCH 3/8] feat: changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e016e2ec..b7bf6700 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - updated github workflows to use the newest versions of the actions - removed unused code +### Thanks + +Thank you to [@reva](https://github.com/reva) for the improvements on +[#292](https://github.com/lucassabreu/clockify-cli/pull/292). + ## [v0.62.0] - 2026-03-20 ### Added From c91719666497644f4c9760a41f60af2991c81ef0 Mon Sep 17 00:00:00 2001 From: Lucas dos Santos Abreu Date: Thu, 26 Mar 2026 09:24:53 -0300 Subject: [PATCH 4/8] fix: lint --- CHANGELOG.md | 1 + api/httpClient.go | 6 +++--- cmd/clockify-cli/main.go | 4 ++-- internal/consoletest/test.go | 4 ++-- pkg/cmd/client/add/add.go | 5 ----- pkg/output/task/quiet.go | 4 +++- pkg/output/user/quiet.go | 4 +++- pkg/output/workspace/quiet.go | 4 +++- 8 files changed, 17 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b7bf6700..b69387b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - updated github workflows to use the newest versions of the actions - removed unused code +- fixed assorted lint errors ### Thanks diff --git a/api/httpClient.go b/api/httpClient.go index 503d9a37..ef469441 100644 --- a/api/httpClient.go +++ b/api/httpClient.go @@ -76,15 +76,15 @@ func (c *client) NewRequest(method, uri string, body interface{}) (*http.Request // Do executes a http.Request inside the Clockify's Client func (c *client) Do( - req *http.Request, v interface{}, name string) (*http.Response, error) { + req *http.Request, v interface{}, name string) (r *http.Response, err error) { <-c.requestTickets - r, err := c.Client.Do(req) + r, err = c.Client.Do(req) if err != nil { return r, err } - defer r.Body.Close() + defer func() { err = r.Body.Close() }() buf := new(bytes.Buffer) diff --git a/cmd/clockify-cli/main.go b/cmd/clockify-cli/main.go index b0bebf2f..8d12b32d 100644 --- a/cmd/clockify-cli/main.go +++ b/cmd/clockify-cli/main.go @@ -70,9 +70,9 @@ func execute() int { } if f.Config().IsDebuging() { - fmt.Fprintf(stderr, "%+v\n", err) + _, _ = fmt.Fprintf(stderr, "%+v\n", err) } else { - fmt.Fprintln(stderr, err.Error()) + _, _ = fmt.Fprintln(stderr, err.Error()) } return exitError diff --git a/internal/consoletest/test.go b/internal/consoletest/test.go index 06cd5bb1..73e565fd 100644 --- a/internal/consoletest/test.go +++ b/internal/consoletest/test.go @@ -89,7 +89,7 @@ func RunTestConsole( if err != nil { t.Fatalf("failed to create console: %v", err) } - defer c.Close() + defer func() { _ = c.Close() }() finished := false t.Cleanup(func() { @@ -109,7 +109,7 @@ func RunTestConsole( }() go func() { - defer c.Tty().Close() + defer func() { _ = c.Tty().Close() }() if err = setup(c.Tty(), c.Tty()); err != nil { t.Error(err) return diff --git a/pkg/cmd/client/add/add.go b/pkg/cmd/client/add/add.go index 9dc3b55d..948c8874 100644 --- a/pkg/cmd/client/add/add.go +++ b/pkg/cmd/client/add/add.go @@ -8,7 +8,6 @@ import ( "github.com/lucassabreu/clockify-cli/api/dto" "github.com/lucassabreu/clockify-cli/pkg/cmd/client/util" "github.com/lucassabreu/clockify-cli/pkg/cmdutil" - "github.com/lucassabreu/clockify-cli/pkg/output/client" "github.com/spf13/cobra" ) @@ -66,10 +65,6 @@ func NewCmdAdd( return report(out, &of, cl) } - if of.JSON { - client.ClientJSONPrint(cl, out) - } - return util.Report([]dto.Client{cl}, out, of) }, } diff --git a/pkg/output/task/quiet.go b/pkg/output/task/quiet.go index a4118bef..7a25c015 100644 --- a/pkg/output/task/quiet.go +++ b/pkg/output/task/quiet.go @@ -10,7 +10,9 @@ import ( // TaskPrintQuietly will only print the IDs func TaskPrintQuietly(ts []dto.Task, w io.Writer) error { for i := 0; i < len(ts); i++ { - fmt.Fprintln(w, ts[i].ID) + if _, err := fmt.Fprintln(w, ts[i].ID); err != nil { + return err + } } return nil diff --git a/pkg/output/user/quiet.go b/pkg/output/user/quiet.go index 11fc0120..1fd736cc 100644 --- a/pkg/output/user/quiet.go +++ b/pkg/output/user/quiet.go @@ -10,7 +10,9 @@ import ( // UserPrintQuietly will only print the IDs func UserPrintQuietly(users []dto.User, w io.Writer) error { for i := 0; i < len(users); i++ { - fmt.Fprintln(w, users[i].ID) + if _, err := fmt.Fprintln(w, users[i].ID); err != nil { + return err + } } return nil diff --git a/pkg/output/workspace/quiet.go b/pkg/output/workspace/quiet.go index db20f404..40c7d38a 100644 --- a/pkg/output/workspace/quiet.go +++ b/pkg/output/workspace/quiet.go @@ -10,7 +10,9 @@ import ( // WorkspacePrintQuietly will only print the IDs func WorkspacePrintQuietly(ws []dto.Workspace, w io.Writer) error { for i := 0; i < len(ws); i++ { - fmt.Fprintln(w, ws[i].ID) + if _, err := fmt.Fprintln(w, ws[i].ID); err != nil { + return err + } } return nil From 69fda7ba91a0672ced4901042ebb269adb88aec5 Mon Sep 17 00:00:00 2001 From: Lucas dos Santos Abreu Date: Thu, 26 Mar 2026 09:27:54 -0300 Subject: [PATCH 5/8] fix: only if needed --- .github/workflows/golangci-lint.yml | 1 - .github/workflows/test-unit.yaml | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index bedf24b7..fe6edfec 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -4,7 +4,6 @@ on: tags: - v* branches: - - master - main pull_request: permissions: diff --git a/.github/workflows/test-unit.yaml b/.github/workflows/test-unit.yaml index ef63a3be..11497552 100644 --- a/.github/workflows/test-unit.yaml +++ b/.github/workflows/test-unit.yaml @@ -2,6 +2,10 @@ name: Unit Tests on: pull_request: push: + tags: + - v* + branches: + - main jobs: tests: runs-on: ubuntu-latest From 0c9a7b190bbc6b7940dcc6c46cabed09c57dc106 Mon Sep 17 00:00:00 2001 From: Lucas dos Santos Abreu Date: Thu, 26 Mar 2026 09:30:03 -0300 Subject: [PATCH 6/8] fix: only assign if needed --- api/httpClient.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/api/httpClient.go b/api/httpClient.go index ef469441..9ba17d72 100644 --- a/api/httpClient.go +++ b/api/httpClient.go @@ -84,7 +84,11 @@ func (c *client) Do( if err != nil { return r, err } - defer func() { err = r.Body.Close() }() + defer func() { + if e := r.Body.Close(); e != nil { + err = e + } + }() buf := new(bytes.Buffer) From 91123c07daafeb9428ec4548eb4362ae097fd76f Mon Sep 17 00:00:00 2001 From: Lucas dos Santos Abreu Date: Thu, 26 Mar 2026 09:32:46 -0300 Subject: [PATCH 7/8] fix: more "ignored" errors --- pkg/output/client/quiet.go | 4 +++- pkg/output/project/quiet.go | 4 +++- pkg/output/tag/quiet.go | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/pkg/output/client/quiet.go b/pkg/output/client/quiet.go index d3130796..7c07f352 100644 --- a/pkg/output/client/quiet.go +++ b/pkg/output/client/quiet.go @@ -10,7 +10,9 @@ import ( // ClientPrintQuietly will only print the IDs func ClientPrintQuietly(cs []dto.Client, w io.Writer) error { for i := 0; i < len(cs); i++ { - fmt.Fprintln(w, cs[i].ID) + if _, err := fmt.Fprintln(w, cs[i].ID); err != nil { + return err + } } return nil diff --git a/pkg/output/project/quiet.go b/pkg/output/project/quiet.go index 0c6e7513..e8614209 100644 --- a/pkg/output/project/quiet.go +++ b/pkg/output/project/quiet.go @@ -10,7 +10,9 @@ import ( // ProjectPrintQuietly will only print the IDs func ProjectPrintQuietly(ps []dto.Project, w io.Writer) error { for i := 0; i < len(ps); i++ { - fmt.Fprintln(w, ps[i].ID) + if _, err := fmt.Fprintln(w, ps[i].ID); err != nil { + return err + } } return nil diff --git a/pkg/output/tag/quiet.go b/pkg/output/tag/quiet.go index 96add83d..ba1448b0 100644 --- a/pkg/output/tag/quiet.go +++ b/pkg/output/tag/quiet.go @@ -10,7 +10,9 @@ import ( // TagPrintQuietly will only print the IDs func TagPrintQuietly(ts []dto.Tag, w io.Writer) error { for i := 0; i < len(ts); i++ { - fmt.Fprintln(w, ts[i].ID) + if _, err := fmt.Fprintln(w, ts[i].ID); err != nil { + return err + } } return nil From 4d58baaa63d4922dcc6bfde6a10b9fae48e598fa Mon Sep 17 00:00:00 2001 From: Lucas dos Santos Abreu Date: Thu, 26 Mar 2026 09:40:00 -0300 Subject: [PATCH 8/8] fix: more "ignored" errors --- cmd/clockify-cli/main.go | 6 +++--- pkg/cmd/version/version.go | 6 ++++-- pkg/output/time-entry/quiet.go | 4 +++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/cmd/clockify-cli/main.go b/cmd/clockify-cli/main.go index 8d12b32d..19af774a 100644 --- a/cmd/clockify-cli/main.go +++ b/cmd/clockify-cli/main.go @@ -58,14 +58,14 @@ func execute() int { stderr := cmd.ErrOrStderr() if errors.Is(err, terminal.InterruptErr) { - fmt.Fprintln(stderr) + _, _ = fmt.Fprintln(stderr) return exitCancel } var flagError *cmdutil.FlagError if errors.As(err, &flagError) { - fmt.Fprintln(stderr, flagError.Error()) - fmt.Fprintln(stderr, cmd.UsageString()) + _, _ = fmt.Fprintln(stderr, flagError.Error()) + _, _ = fmt.Fprintln(stderr, cmd.UsageString()) return exitError } diff --git a/pkg/cmd/version/version.go b/pkg/cmd/version/version.go index 8de3a5d1..28968b8d 100644 --- a/pkg/cmd/version/version.go +++ b/pkg/cmd/version/version.go @@ -12,11 +12,13 @@ func NewCmdVersion(f cmdutil.Factory) *cobra.Command { return &cobra.Command{ Use: "version", Short: "Shows the CLI version", - Run: func(cmd *cobra.Command, _ []string) { + RunE: func(cmd *cobra.Command, _ []string) error { v := f.Version() - fmt.Fprintln(cmd.OutOrStdout(), + _, err := fmt.Fprintln(cmd.OutOrStdout(), "Version: "+v.Tag+", Commit: "+v.Commit+", Build At: "+v.Date, ) + + return err }, } } diff --git a/pkg/output/time-entry/quiet.go b/pkg/output/time-entry/quiet.go index 3dd8bb63..dc5d0e8e 100644 --- a/pkg/output/time-entry/quiet.go +++ b/pkg/output/time-entry/quiet.go @@ -10,7 +10,9 @@ import ( // TimeEntriesPrintQuietly will only print the IDs func TimeEntriesPrintQuietly(timeEntries []dto.TimeEntry, w io.Writer) error { for i := 0; i < len(timeEntries); i++ { - fmt.Fprintln(w, timeEntries[i].ID) + if _, err := fmt.Fprintln(w, timeEntries[i].ID); err != nil { + return err + } } return nil