Fix lint errors
This commit is contained in:
parent
fe4c293adb
commit
83e809dbbb
|
|
@ -0,0 +1,6 @@
|
|||
version: "2"
|
||||
|
||||
linters:
|
||||
exclusions:
|
||||
presets:
|
||||
- std-error-handling
|
||||
|
|
@ -75,7 +75,9 @@ func main() {
|
|||
log.Println("Shutting down...")
|
||||
shutdownCtx, shutdownCancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer shutdownCancel()
|
||||
srv.Shutdown(shutdownCtx)
|
||||
if err := srv.Shutdown(shutdownCtx); err != nil {
|
||||
log.Printf("Shutdown error: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
log.Printf("Cairn server listening on %s", cfg.ListenAddr)
|
||||
|
|
|
|||
|
|
@ -183,7 +183,9 @@ func cmdUpload(args []string) error {
|
|||
}
|
||||
|
||||
var result map[string]any
|
||||
json.Unmarshal(body, &result)
|
||||
if err := json.Unmarshal(body, &result); err != nil {
|
||||
return fmt.Errorf("parsing response: %w", err)
|
||||
}
|
||||
fmt.Printf("Artifact uploaded: %s\n", result["id"])
|
||||
|
||||
return nil
|
||||
|
|
@ -244,7 +246,9 @@ func cmdCheck(args []string) error {
|
|||
Fixed []string `json:"fixed"`
|
||||
Recurring []string `json:"recurring"`
|
||||
}
|
||||
json.Unmarshal(respBody, &result)
|
||||
if err := json.Unmarshal(respBody, &result); err != nil {
|
||||
return fmt.Errorf("parsing response: %w", err)
|
||||
}
|
||||
|
||||
if result.IsRegression {
|
||||
fmt.Printf("REGRESSION: %d new crash signature(s)\n", len(result.New))
|
||||
|
|
@ -301,7 +305,9 @@ func cmdCampaign(subcmd string, args []string) error {
|
|||
return fmt.Errorf("server returned %d: %s", resp.StatusCode, respBody)
|
||||
}
|
||||
var result map[string]any
|
||||
json.Unmarshal(respBody, &result)
|
||||
if err := json.Unmarshal(respBody, &result); err != nil {
|
||||
return fmt.Errorf("parsing response: %w", err)
|
||||
}
|
||||
fmt.Printf("Campaign started: %s\n", result["id"])
|
||||
|
||||
case "finish":
|
||||
|
|
|
|||
|
|
@ -63,12 +63,12 @@ func Migrate(ctx context.Context, pool *pgxpool.Pool) error {
|
|||
}
|
||||
|
||||
if _, err := tx.Exec(ctx, string(sql)); err != nil {
|
||||
tx.Rollback(ctx)
|
||||
_ = tx.Rollback(ctx)
|
||||
return fmt.Errorf("executing migration %s: %w", version, err)
|
||||
}
|
||||
|
||||
if _, err := tx.Exec(ctx, "INSERT INTO schema_migrations (version) VALUES ($1)", version); err != nil {
|
||||
tx.Rollback(ctx)
|
||||
_ = tx.Rollback(ctx)
|
||||
return fmt.Errorf("recording migration %s: %w", version, err)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ func (c *Client) do(ctx context.Context, method, path string, body any) (*http.R
|
|||
|
||||
if resp.StatusCode >= 400 {
|
||||
respBody, _ := io.ReadAll(resp.Body)
|
||||
resp.Body.Close()
|
||||
_ = resp.Body.Close()
|
||||
return nil, fmt.Errorf("forgejo API %s %s: %d %s", method, path, resp.StatusCode, string(respBody))
|
||||
}
|
||||
|
||||
|
|
@ -149,6 +149,6 @@ func (c *Client) patch(ctx context.Context, path string, body any) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
resp.Body.Close()
|
||||
_ = resp.Body.Close()
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,11 +42,11 @@ func (h *DashboardHandler) Stats(c *gin.Context) {
|
|||
ctx := c.Request.Context()
|
||||
var stats DashboardStats
|
||||
|
||||
h.Pool.QueryRow(ctx, "SELECT COUNT(*) FROM artifacts").Scan(&stats.TotalArtifacts)
|
||||
h.Pool.QueryRow(ctx, "SELECT COUNT(*) FROM repositories").Scan(&stats.TotalRepos)
|
||||
h.Pool.QueryRow(ctx, "SELECT COUNT(*) FROM crash_groups").Scan(&stats.TotalCrashGroups)
|
||||
h.Pool.QueryRow(ctx, "SELECT COUNT(*) FROM crash_groups WHERE status = 'open'").Scan(&stats.OpenCrashGroups)
|
||||
h.Pool.QueryRow(ctx, "SELECT COUNT(*) FROM campaigns WHERE status = 'running'").Scan(&stats.ActiveCampaigns)
|
||||
_ = h.Pool.QueryRow(ctx, "SELECT COUNT(*) FROM artifacts").Scan(&stats.TotalArtifacts)
|
||||
_ = h.Pool.QueryRow(ctx, "SELECT COUNT(*) FROM repositories").Scan(&stats.TotalRepos)
|
||||
_ = h.Pool.QueryRow(ctx, "SELECT COUNT(*) FROM crash_groups").Scan(&stats.TotalCrashGroups)
|
||||
_ = h.Pool.QueryRow(ctx, "SELECT COUNT(*) FROM crash_groups WHERE status = 'open'").Scan(&stats.OpenCrashGroups)
|
||||
_ = h.Pool.QueryRow(ctx, "SELECT COUNT(*) FROM campaigns WHERE status = 'running'").Scan(&stats.ActiveCampaigns)
|
||||
|
||||
// Artifact trend for the last 30 days.
|
||||
var trend []TrendPoint
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ func (h *IngestHandler) Create(c *gin.Context) {
|
|||
if result := fingerprint.Compute(req.StackTrace); result != nil {
|
||||
sig, isNew, err := models.GetOrCreateSignature(ctx, h.Pool, repo.ID, result.Fingerprint, stackTrace)
|
||||
if err == nil {
|
||||
models.UpdateArtifactSignature(ctx, h.Pool, artifact.ID, sig.ID, result.Fingerprint)
|
||||
_ = models.UpdateArtifactSignature(ctx, h.Pool, artifact.ID, sig.ID, result.Fingerprint)
|
||||
|
||||
if isNew {
|
||||
title := req.Type + " crash in " + req.Repository
|
||||
|
|
@ -115,7 +115,7 @@ func (h *IngestHandler) Create(c *gin.Context) {
|
|||
}
|
||||
group, groupErr := models.CreateCrashGroup(ctx, h.Pool, sig.ID, repo.ID, title)
|
||||
if groupErr == nil && h.ForgejoSync != nil {
|
||||
h.ForgejoSync.CreateIssueForCrashGroup(ctx, group, req.StackTrace)
|
||||
_ = h.ForgejoSync.CreateIssueForCrashGroup(ctx, group, req.StackTrace)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -148,5 +148,5 @@ func (h *DownloadHandler) Download(c *gin.Context) {
|
|||
|
||||
c.Header("Content-Disposition", fmt.Sprintf("attachment; filename=%q", artifact.BlobKey))
|
||||
c.Header("Content-Type", "application/octet-stream")
|
||||
io.Copy(c.Writer, reader)
|
||||
_, _ = io.Copy(c.Writer, reader)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ func (h *RegressionHandler) Check(c *gin.Context) {
|
|||
description = fmt.Sprintf("%d new crash signature(s) detected", len(result.New))
|
||||
}
|
||||
|
||||
h.ForgejoSync.Client.CreateCommitStatus(ctx, repo.Owner, repo.Name, req.HeadSHA, forgejo.CommitStatus{
|
||||
_ = h.ForgejoSync.Client.CreateCommitStatus(ctx, repo.Owner, repo.Name, req.HeadSHA, forgejo.CommitStatus{
|
||||
State: state,
|
||||
Description: description,
|
||||
Context: "cairn/regression",
|
||||
|
|
|
|||
|
|
@ -38,8 +38,8 @@ func (h *PageHandler) Index(c *gin.Context) {
|
|||
}
|
||||
|
||||
var totalCG, openCG int
|
||||
h.Pool.QueryRow(ctx, "SELECT COUNT(*) FROM crash_groups").Scan(&totalCG)
|
||||
h.Pool.QueryRow(ctx, "SELECT COUNT(*) FROM crash_groups WHERE status = 'open'").Scan(&openCG)
|
||||
_ = h.Pool.QueryRow(ctx, "SELECT COUNT(*) FROM crash_groups").Scan(&totalCG)
|
||||
_ = h.Pool.QueryRow(ctx, "SELECT COUNT(*) FROM crash_groups WHERE status = 'open'").Scan(&openCG)
|
||||
|
||||
// Top crashers
|
||||
type topCrasher struct {
|
||||
|
|
@ -80,7 +80,7 @@ func (h *PageHandler) Index(c *gin.Context) {
|
|||
},
|
||||
}
|
||||
c.Header("Content-Type", "text/html; charset=utf-8")
|
||||
h.Templates.Render(c.Writer, "index", data)
|
||||
_ = h.Templates.Render(c.Writer, "index", data)
|
||||
}
|
||||
|
||||
func (h *PageHandler) Artifacts(c *gin.Context) {
|
||||
|
|
@ -111,7 +111,7 @@ func (h *PageHandler) Artifacts(c *gin.Context) {
|
|||
},
|
||||
}
|
||||
c.Header("Content-Type", "text/html; charset=utf-8")
|
||||
h.Templates.Render(c.Writer, "artifacts", data)
|
||||
_ = h.Templates.Render(c.Writer, "artifacts", data)
|
||||
}
|
||||
|
||||
func (h *PageHandler) ArtifactDetail(c *gin.Context) {
|
||||
|
|
@ -128,7 +128,7 @@ func (h *PageHandler) ArtifactDetail(c *gin.Context) {
|
|||
Content: artifact,
|
||||
}
|
||||
c.Header("Content-Type", "text/html; charset=utf-8")
|
||||
h.Templates.Render(c.Writer, "artifact_detail", data)
|
||||
_ = h.Templates.Render(c.Writer, "artifact_detail", data)
|
||||
}
|
||||
|
||||
func (h *PageHandler) Repos(c *gin.Context) {
|
||||
|
|
@ -145,7 +145,7 @@ func (h *PageHandler) Repos(c *gin.Context) {
|
|||
},
|
||||
}
|
||||
c.Header("Content-Type", "text/html; charset=utf-8")
|
||||
h.Templates.Render(c.Writer, "repos", data)
|
||||
_ = h.Templates.Render(c.Writer, "repos", data)
|
||||
}
|
||||
|
||||
func (h *PageHandler) CrashGroups(c *gin.Context) {
|
||||
|
|
@ -175,7 +175,7 @@ func (h *PageHandler) CrashGroups(c *gin.Context) {
|
|||
},
|
||||
}
|
||||
c.Header("Content-Type", "text/html; charset=utf-8")
|
||||
h.Templates.Render(c.Writer, "crashgroups", data)
|
||||
_ = h.Templates.Render(c.Writer, "crashgroups", data)
|
||||
}
|
||||
|
||||
func (h *PageHandler) CrashGroupDetail(c *gin.Context) {
|
||||
|
|
@ -201,7 +201,7 @@ func (h *PageHandler) CrashGroupDetail(c *gin.Context) {
|
|||
},
|
||||
}
|
||||
c.Header("Content-Type", "text/html; charset=utf-8")
|
||||
h.Templates.Render(c.Writer, "crashgroup_detail", data)
|
||||
_ = h.Templates.Render(c.Writer, "crashgroup_detail", data)
|
||||
}
|
||||
|
||||
func (h *PageHandler) Search(c *gin.Context) {
|
||||
|
|
@ -222,7 +222,7 @@ func (h *PageHandler) Search(c *gin.Context) {
|
|||
},
|
||||
}
|
||||
c.Header("Content-Type", "text/html; charset=utf-8")
|
||||
h.Templates.Render(c.Writer, "search", data)
|
||||
_ = h.Templates.Render(c.Writer, "search", data)
|
||||
}
|
||||
|
||||
func (h *PageHandler) Regression(c *gin.Context) {
|
||||
|
|
@ -252,7 +252,7 @@ func (h *PageHandler) Regression(c *gin.Context) {
|
|||
Content: content,
|
||||
}
|
||||
c.Header("Content-Type", "text/html; charset=utf-8")
|
||||
h.Templates.Render(c.Writer, "regression", data)
|
||||
_ = h.Templates.Render(c.Writer, "regression", data)
|
||||
}
|
||||
|
||||
func (h *PageHandler) Campaigns(c *gin.Context) {
|
||||
|
|
@ -276,7 +276,7 @@ func (h *PageHandler) Campaigns(c *gin.Context) {
|
|||
},
|
||||
}
|
||||
c.Header("Content-Type", "text/html; charset=utf-8")
|
||||
h.Templates.Render(c.Writer, "campaigns", data)
|
||||
_ = h.Templates.Render(c.Writer, "campaigns", data)
|
||||
}
|
||||
|
||||
func (h *PageHandler) CampaignDetail(c *gin.Context) {
|
||||
|
|
@ -301,5 +301,5 @@ func (h *PageHandler) CampaignDetail(c *gin.Context) {
|
|||
},
|
||||
}
|
||||
c.Header("Content-Type", "text/html; charset=utf-8")
|
||||
h.Templates.Render(c.Writer, "campaign_detail", data)
|
||||
_ = h.Templates.Render(c.Writer, "campaign_detail", data)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue