From 5f65705005fec3bbc8713da98ffd0cdbfb3bef82 Mon Sep 17 00:00:00 2001 From: Kujtim Hoxha Date: Mon, 30 Jun 2025 14:13:08 +0200 Subject: [PATCH] fix: resolve golangci-lint issues - Fix gofumpt formatting in models.go - Replace deprecated database methods with context-aware versions: - db.Ping() -> db.PingContext() - db.Exec() -> db.ExecContext() - db.Begin() -> db.BeginTx() - Update Taskfile.yaml to match CI lint configuration --- Taskfile.yaml | 4 ++-- internal/db/connect.go | 5 +++-- internal/history/file.go | 2 +- internal/tui/components/dialogs/models/models.go | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Taskfile.yaml b/Taskfile.yaml index 9453eb363513d5b9e0987a637d761eef1bfe63c3..077c994ea7c6ce79fabbc18f76cfb3ef27af8d5e 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -6,12 +6,12 @@ tasks: lint: desc: Run base linters cmds: - - golangci-lint run + - golangci-lint run --path-mode=abs --config=".golangci.yml" --timeout=5m lint-fix: desc: Run base linters and fix issues cmds: - - golangci-lint run --fix + - golangci-lint run --path-mode=abs --config=".golangci.yml" --timeout=5m --fix test: desc: Run tests diff --git a/internal/db/connect.go b/internal/db/connect.go index 83c647d846fc07c5ba3ecce3efae8a70c89c08e1..01e932a208a23241622bd7a9bf930d826c1e0d59 100644 --- a/internal/db/connect.go +++ b/internal/db/connect.go @@ -1,6 +1,7 @@ package db import ( + "context" "database/sql" "fmt" "os" @@ -31,7 +32,7 @@ func Connect() (*sql.DB, error) { } // Verify connection - if err = db.Ping(); err != nil { + if err = db.PingContext(context.Background()); err != nil { db.Close() return nil, fmt.Errorf("failed to connect to database: %w", err) } @@ -46,7 +47,7 @@ func Connect() (*sql.DB, error) { } for _, pragma := range pragmas { - if _, err = db.Exec(pragma); err != nil { + if _, err = db.ExecContext(context.Background(), pragma); err != nil { logging.Error("Failed to set pragma", pragma, err) } else { logging.Debug("Set pragma", "pragma", pragma) diff --git a/internal/history/file.go b/internal/history/file.go index d8fe6088626be28262f06485c07c95693ddfd219..7317f012fd83b31990bbc701261eed91794a52a5 100644 --- a/internal/history/file.go +++ b/internal/history/file.go @@ -83,7 +83,7 @@ func (s *service) createWithVersion(ctx context.Context, sessionID, path, conten // Retry loop for transaction conflicts for attempt := range maxRetries { // Start a transaction - tx, txErr := s.db.Begin() + tx, txErr := s.db.BeginTx(ctx, nil) if txErr != nil { return File{}, fmt.Errorf("failed to begin transaction: %w", txErr) } diff --git a/internal/tui/components/dialogs/models/models.go b/internal/tui/components/dialogs/models/models.go index 8e81777d7e3e6c45628cb8839b52c484e47f5640..c2c65e5d90c1d9bf9bfca708692f0f288c27a594 100644 --- a/internal/tui/components/dialogs/models/models.go +++ b/internal/tui/components/dialogs/models/models.go @@ -219,7 +219,7 @@ func (m *modelDialogCmp) SetModelType(modelType int) tea.Cmd { providers := config.Providers() modelItems := []util.Model{} selectIndex := 0 - + cfg := config.Get() var currentModel config.PreferredModel if m.modelType == LargeModelType { @@ -227,7 +227,7 @@ func (m *modelDialogCmp) SetModelType(modelType int) tea.Cmd { } else { currentModel = cfg.Models.Small } - + for _, provider := range providers { name := provider.Name if name == "" {