From f5b997bfc4c77ef262726d14b30d387eb7acd1c6 Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Sun, 25 Jan 2026 20:55:58 -1000 Subject: Fix all static analysis errors (golangci-lint) - Fix errcheck: handle all error return values in production code - Fix errcheck: handle all error return values in test files - Fix staticcheck: replace deprecated WithCredentialsFile with WithAuthCredentialsFile - Remove unused code: authHeaders, planToEatPlannerItem, planToEatResponse - Use defer func() { _ = x.Close() }() pattern for ignored close errors Co-Authored-By: Claude Opus 4.5 --- internal/api/plantoeat.go | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) (limited to 'internal/api/plantoeat.go') diff --git a/internal/api/plantoeat.go b/internal/api/plantoeat.go index a7fdf58..5c24cc1 100644 --- a/internal/api/plantoeat.go +++ b/internal/api/plantoeat.go @@ -39,27 +39,6 @@ func (c *PlanToEatClient) SetSessionCookie(cookie string) { c.sessionCookie = cookie } -func (c *PlanToEatClient) authHeaders() map[string]string { - return map[string]string{"Authorization": "Bearer " + c.apiKey} -} - -// planToEatPlannerItem represents a planner item from the API -type planToEatPlannerItem struct { - ID int `json:"id"` - Date string `json:"date"` - MealType string `json:"meal_type"` - Recipe struct { - ID int `json:"id"` - Title string `json:"title"` - URL string `json:"url"` - } `json:"recipe"` -} - -// planToEatResponse wraps the API response -type planToEatResponse struct { - Items []planToEatPlannerItem `json:"items"` -} - // GetUpcomingMeals fetches meals by scraping the planner web interface // Requires a valid session cookie set via SetSessionCookie func (c *PlanToEatClient) GetUpcomingMeals(ctx context.Context, days int) ([]models.Meal, error) { @@ -84,7 +63,7 @@ func (c *PlanToEatClient) GetUpcomingMeals(ctx context.Context, days int) ([]mod if err != nil { return nil, fmt.Errorf("request failed: %w", err) } - defer resp.Body.Close() + defer func() { _ = resp.Body.Close() }() log.Printf("DEBUG [PlanToEat/Meals]: Response status %d", resp.StatusCode) @@ -238,7 +217,7 @@ func (c *PlanToEatClient) GetShoppingList(ctx context.Context) ([]models.Shoppin if err != nil { return nil, fmt.Errorf("request failed: %w", err) } - defer resp.Body.Close() + defer func() { _ = resp.Body.Close() }() log.Printf("DEBUG [PlanToEat/Shopping]: Response status %d", resp.StatusCode) -- cgit v1.2.3