From abd11cfd08430ec5f9d2c6dbd0e0f798816922d1 Mon Sep 17 00:00:00 2001 From: Taras Madan Date: Tue, 15 Jul 2025 16:43:33 +0200 Subject: all: apply linter auto fixes ./tools/syz-env bin/golangci-lint run ./... --fix --- dashboard/app/jobs.go | 5 +++-- dashboard/app/kcidb.go | 9 ++------- dashboard/app/main.go | 6 +++--- dashboard/app/reporting.go | 5 +++-- dashboard/app/util_test.go | 5 +++-- 5 files changed, 14 insertions(+), 16 deletions(-) (limited to 'dashboard/app') diff --git a/dashboard/app/jobs.go b/dashboard/app/jobs.go index f5f629d81..b7ff881a3 100644 --- a/dashboard/app/jobs.go +++ b/dashboard/app/jobs.go @@ -940,10 +940,11 @@ func handleRetestedRepro(c context.Context, now time.Time, job *Job, jobKey *db. crash.LastReproRetest = now if req.Error == nil && !crash.ReproIsRevoked { // If repro testing itself failed, it might be just a temporary issue. - if job.Type == JobTestPatch { + switch job.Type { + case JobTestPatch: // If there was any crash at all, the repro is still not worth discarding. crash.ReproIsRevoked = len(allTitles) == 0 - } else if job.Type == JobBisectFix { + case JobBisectFix: // More than one commit is suspected => repro stopped working at some point. crash.ReproIsRevoked = len(req.Commits) > 0 } diff --git a/dashboard/app/kcidb.go b/dashboard/app/kcidb.go index 6fe641276..7203c6dfa 100644 --- a/dashboard/app/kcidb.go +++ b/dashboard/app/kcidb.go @@ -69,13 +69,8 @@ func publishKcidbBug(c context.Context, client *kcidb.Client, bug *Bug, bugKey * if err != nil { return false, err } - publish := true - if rep.KernelCommit == "" || len(rep.KernelConfig) == 0 { - // This should happen only for syzkaller build/test errors, which we don't want to publish. - // But if this ever happens for a kernel bug, then we also don't want to publish such bugs - // with missing critical info. - publish = false - } + publish := !(rep.KernelCommit == "" || len(rep.KernelConfig) == 0) + if publish { if err := client.Publish(rep); err != nil { return false, err diff --git a/dashboard/app/main.go b/dashboard/app/main.go index 78aed619f..eeba85c9e 100644 --- a/dashboard/app/main.go +++ b/dashboard/app/main.go @@ -1315,7 +1315,7 @@ func debugBugSubsystems(c context.Context, w http.ResponseWriter, bug *Bug) erro TraceWriter: w, }) if err != nil { - w.Write([]byte(fmt.Sprintf("%s", err))) + fmt.Fprintf(w, "%s", err) } return nil } @@ -2407,8 +2407,8 @@ func invalidateJobLink(c context.Context, job *Job, jobKey *db.Key, restart bool func formatLogLine(line string) string { const maxLineLen = 1000 - line = strings.Replace(line, "\n", " ", -1) - line = strings.Replace(line, "\r", "", -1) + line = strings.ReplaceAll(line, "\n", " ") + line = strings.ReplaceAll(line, "\r", "") if len(line) > maxLineLen { line = line[:maxLineLen] line += "..." diff --git a/dashboard/app/reporting.go b/dashboard/app/reporting.go index b73bab8ac..c5e6ff1e3 100644 --- a/dashboard/app/reporting.go +++ b/dashboard/app/reporting.go @@ -1288,11 +1288,12 @@ func findCrashForBug(c context.Context, bug *Bug) (*Crash, *db.Key, error) { return nil, nil, fmt.Errorf("no crashes") } crash, key := crashes[0], keys[0] - if bug.HeadReproLevel == ReproLevelC { + switch bug.HeadReproLevel { + case ReproLevelC: if crash.ReproC == 0 { log.Errorf(c, "bug '%v': has C repro, but crash without C repro", bug.Title) } - } else if bug.HeadReproLevel == ReproLevelSyz { + case ReproLevelSyz: if crash.ReproSyz == 0 { log.Errorf(c, "bug '%v': has syz repro, but crash without syz repro", bug.Title) } diff --git a/dashboard/app/util_test.go b/dashboard/app/util_test.go index f9e2ad660..2040f879e 100644 --- a/dashboard/app/util_test.go +++ b/dashboard/app/util_test.go @@ -357,9 +357,10 @@ func (c *Ctx) httpRequest(method, url, body, contentType string, } r = registerRequest(r, c) r = r.WithContext(c.transformContext(r.Context())) - if access == AccessAdmin { + switch access { + case AccessAdmin: aetest.Login(makeUser(AuthorizedAdmin), r) - } else if access == AccessUser { + case AccessUser: aetest.Login(makeUser(AuthorizedUser), r) } w := httptest.NewRecorder() -- cgit mrf-deployment