diff options
Diffstat (limited to 'internal/handlers')
| -rw-r--r-- | internal/handlers/handlers.go | 29 | ||||
| -rw-r--r-- | internal/handlers/handlers_test.go | 12 | ||||
| -rw-r--r-- | internal/handlers/response.go | 4 | ||||
| -rw-r--r-- | internal/handlers/tab_state_test.go | 4 | ||||
| -rw-r--r-- | internal/handlers/timeline_logic_test.go | 8 |
5 files changed, 29 insertions, 28 deletions
diff --git a/internal/handlers/handlers.go b/internal/handlers/handlers.go index e0e185d..a169478 100644 --- a/internal/handlers/handlers.go +++ b/internal/handlers/handlers.go @@ -659,9 +659,9 @@ func (h *Handler) handleAtomToggle(w http.ResponseWriter, r *http.Request, compl // Remove from local cache switch source { case "todoist": - h.store.DeleteTask(id) + _ = h.store.DeleteTask(id) case "trello": - h.store.DeleteCard(id) + _ = h.store.DeleteCard(id) } // Return completed task HTML with uncomplete option @@ -675,9 +675,9 @@ func (h *Handler) handleAtomToggle(w http.ResponseWriter, r *http.Request, compl // Invalidate cache to force refresh switch source { case "todoist": - h.store.InvalidateCache(store.CacheKeyTodoistTasks) + _ = h.store.InvalidateCache(store.CacheKeyTodoistTasks) case "trello": - h.store.InvalidateCache(store.CacheKeyTrelloBoards) + _ = h.store.InvalidateCache(store.CacheKeyTrelloBoards) } // Don't swap empty response - just trigger refresh w.Header().Set("HX-Reswap", "none") @@ -710,10 +710,11 @@ func (h *Handler) getAtomTitle(id, source string) string { case "bug": if bugs, err := h.store.GetBugs(); err == nil { var bugID int64 - fmt.Sscanf(id, "bug-%d", &bugID) - for _, b := range bugs { - if b.ID == bugID { - return b.Description + if _, err := fmt.Sscanf(id, "bug-%d", &bugID); err == nil { + for _, b := range bugs { + if b.ID == bugID { + return b.Description + } } } } @@ -752,7 +753,7 @@ func (h *Handler) HandleUnifiedAdd(w http.ResponseWriter, r *http.Request) { JSONError(w, http.StatusInternalServerError, "Failed to create Todoist task", err) return } - h.store.InvalidateCache(store.CacheKeyTodoistTasks) + _ = h.store.InvalidateCache(store.CacheKeyTodoistTasks) case "trello": listID := r.FormValue("list_id") @@ -764,7 +765,7 @@ func (h *Handler) HandleUnifiedAdd(w http.ResponseWriter, r *http.Request) { JSONError(w, http.StatusInternalServerError, "Failed to create Trello card", err) return } - h.store.InvalidateCache(store.CacheKeyTrelloBoards) + _ = h.store.InvalidateCache(store.CacheKeyTrelloBoards) default: JSONError(w, http.StatusBadRequest, "Invalid source", nil) @@ -791,7 +792,7 @@ func (h *Handler) HandleGetListsOptions(w http.ResponseWriter, r *http.Request) w.Header().Set("Content-Type", "text/html") for _, list := range lists { - fmt.Fprintf(w, `<option value="%s">%s</option>`, list.ID, list.Name) + _, _ = fmt.Fprintf(w, `<option value="%s">%s</option>`, list.ID, list.Name) } } @@ -805,12 +806,12 @@ func (h *Handler) HandleGetBugs(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/html") if len(bugs) == 0 { - fmt.Fprint(w, `<p class="text-gray-500 text-sm">No bugs reported yet.</p>`) + _, _ = fmt.Fprint(w, `<p class="text-gray-500 text-sm">No bugs reported yet.</p>`) return } for _, bug := range bugs { - fmt.Fprintf(w, `<div class="text-sm border-b border-gray-100 py-2"> + _, _ = fmt.Fprintf(w, `<div class="text-sm border-b border-gray-100 py-2"> <p class="text-gray-900">%s</p> <p class="text-gray-400 text-xs">%s</p> </div>`, template.HTMLEscapeString(bug.Description), bug.CreatedAt.Format("Jan 2, 3:04 PM")) @@ -916,7 +917,7 @@ func (h *Handler) HandleGetShoppingLists(w http.ResponseWriter, r *http.Request) w.Header().Set("Content-Type", "text/html") for _, list := range lists { - fmt.Fprintf(w, `<option value="%s">%s</option>`, list.ID, list.Name) + _, _ = fmt.Fprintf(w, `<option value="%s">%s</option>`, list.ID, list.Name) } } diff --git a/internal/handlers/handlers_test.go b/internal/handlers/handlers_test.go index 3658e0e..d863546 100644 --- a/internal/handlers/handlers_test.go +++ b/internal/handlers/handlers_test.go @@ -26,7 +26,7 @@ func setupTestDB(t *testing.T) (*store.Store, func()) { if err != nil { t.Fatalf("Failed to create temp db: %v", err) } - tmpFile.Close() + _ = tmpFile.Close() // Save current directory and change to project root // This ensures migrations can be found @@ -43,18 +43,18 @@ func setupTestDB(t *testing.T) (*store.Store, func()) { // Initialize store (this runs migrations) db, err := store.New(tmpFile.Name(), "migrations") if err != nil { - os.Chdir(originalDir) - os.Remove(tmpFile.Name()) + _ = os.Chdir(originalDir) + _ = os.Remove(tmpFile.Name()) t.Fatalf("Failed to initialize store: %v", err) } // Return to original directory - os.Chdir(originalDir) + _ = os.Chdir(originalDir) // Return cleanup function cleanup := func() { - db.Close() - os.Remove(tmpFile.Name()) + _ = db.Close() + _ = os.Remove(tmpFile.Name()) } return db, cleanup diff --git a/internal/handlers/response.go b/internal/handlers/response.go index 3976f02..9a7ab45 100644 --- a/internal/handlers/response.go +++ b/internal/handlers/response.go @@ -10,7 +10,7 @@ import ( // JSONResponse writes data as JSON with appropriate headers func JSONResponse(w http.ResponseWriter, data interface{}) { w.Header().Set("Content-Type", "application/json") - json.NewEncoder(w).Encode(data) + _ = json.NewEncoder(w).Encode(data) } // JSONError writes an error response as JSON @@ -32,5 +32,5 @@ func HTMLResponse(w http.ResponseWriter, tmpl *template.Template, name string, d // HTMLString writes an HTML string directly func HTMLString(w http.ResponseWriter, html string) { w.Header().Set("Content-Type", "text/html") - w.Write([]byte(html)) + _, _ = w.Write([]byte(html)) } diff --git a/internal/handlers/tab_state_test.go b/internal/handlers/tab_state_test.go index 60f1340..71c6ed8 100644 --- a/internal/handlers/tab_state_test.go +++ b/internal/handlers/tab_state_test.go @@ -17,7 +17,7 @@ func TestHandleDashboard_TabState(t *testing.T) { if err != nil { t.Fatalf("Failed to create test database: %v", err) } - defer db.Close() + defer func() { _ = db.Close() }() // Create mock API clients todoistClient := api.NewTodoistClient("test-key") @@ -75,7 +75,7 @@ func TestHandleDashboard_TabState(t *testing.T) { h.HandleDashboard(w, req) resp := w.Result() - defer resp.Body.Close() + defer func() { _ = resp.Body.Close() }() if resp.StatusCode != http.StatusOK { t.Errorf("Expected status 200, got %d", resp.StatusCode) diff --git a/internal/handlers/timeline_logic_test.go b/internal/handlers/timeline_logic_test.go index a0576d6..038f836 100644 --- a/internal/handlers/timeline_logic_test.go +++ b/internal/handlers/timeline_logic_test.go @@ -96,21 +96,21 @@ func TestBuildTimeline(t *testing.T) { // Task: 10:00 taskDate := baseTime.Add(2 * time.Hour) - s.SaveTasks([]models.Task{ + _ = s.SaveTasks([]models.Task{ {ID: "t1", Content: "Task 1", DueDate: &taskDate}, }) // Meal: Lunch (defaults to 12:00) mealDate := baseTime // Date part matters - s.SaveMeals([]models.Meal{ + _ = s.SaveMeals([]models.Meal{ {ID: "m1", RecipeName: "Lunch", Date: mealDate, MealType: "lunch"}, }) // Card: 14:00 cardDate := baseTime.Add(6 * time.Hour) - s.SaveBoards([]models.Board{ + _ = s.SaveBoards([]models.Board{ { - ID: "b1", + ID: "b1", Name: "Board 1", Cards: []models.Card{ {ID: "c1", Name: "Card 1", DueDate: &cardDate, ListID: "l1"}, |
