From f2066be399e50d27aa20be7ad5ced1d32aad1657 Mon Sep 17 00:00:00 2001 From: Rene Cannao Date: Mon, 23 Mar 2026 18:58:40 +0000 Subject: [PATCH 1/2] chore: add golangci-lint configuration and fix critical lint issues Add a conservative golangci-lint config enabling errcheck, govet, ineffassign, staticcheck, and unused linters. Fix two real bugs caught by staticcheck: - SA1000: invalid regex syntax (?sg) in ts/commands.go (Go doesn't support 'g' flag) - SA1006: fmt.Errorf wrapping fmt.Sprintf unnecessarily in ops/downloads.go --- .golangci.yml | 21 +++++++++++++++++++++ ops/downloads.go | 4 ++-- ts/commands.go | 2 +- 3 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 .golangci.yml diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 00000000..9889acba --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,21 @@ +run: + timeout: 5m + +linters: + enable: + - errcheck + - govet + - ineffassign + - staticcheck + - unused + disable: + - depguard + +linters-settings: + errcheck: + check-type-assertions: false + +issues: + exclude-use-default: true + max-issues-per-linter: 50 + max-same-issues: 10 diff --git a/ops/downloads.go b/ops/downloads.go index b4ccd06c..d206a9b9 100644 --- a/ops/downloads.go +++ b/ops/downloads.go @@ -249,8 +249,8 @@ func findRemoteTarballByVersion(version, flavor, OS, arch string, minimal, newes tarball, err = downloads.FindOrGuessTarballByVersionFlavorOS(version, flavor, OS, arch, minimal, newest, guessLatest) if err != nil { - return downloads.TarballDescription{}, fmt.Errorf(fmt.Sprintf("Error getting version %s (%s-%s)[minimal: %v - newest: %v - guess: %v]: %s", - version, flavor, OS, minimal, newest, guessLatest, err)) + return downloads.TarballDescription{}, fmt.Errorf("Error getting version %s (%s-%s)[minimal: %v - newest: %v - guess: %v]: %s", + version, flavor, OS, minimal, newest, guessLatest, err) } return tarball, nil } diff --git a/ts/commands.go b/ts/commands.go index 64fbe2f1..f3617410 100644 --- a/ts/commands.go +++ b/ts/commands.go @@ -60,7 +60,7 @@ func findErrorsInLogFile(ts *testscript.TestScript, neg bool, args []string) { ts.Check(err) hasError := strings.Contains(string(contents), "ERROR") if neg && hasError { - reLines := regexp.MustCompile(`(?sg)(^.*ERROR.*)`) + reLines := regexp.MustCompile(`(?s)(^.*ERROR.*)`) errorLines := reLines.FindAll(contents, -1) ts.Fatalf("ERRORs found in %s (%s)\n", logFile, errorLines) } From 74e3748247e49ec5c16d5b8b128ae23f97d82c2e Mon Sep 17 00:00:00 2001 From: Rene Cannao Date: Mon, 23 Mar 2026 20:10:01 +0000 Subject: [PATCH 2/2] fix: use multiline regex for ERROR line matching in ts/commands.go --- ts/commands.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ts/commands.go b/ts/commands.go index f3617410..ba2fdb25 100644 --- a/ts/commands.go +++ b/ts/commands.go @@ -60,9 +60,13 @@ func findErrorsInLogFile(ts *testscript.TestScript, neg bool, args []string) { ts.Check(err) hasError := strings.Contains(string(contents), "ERROR") if neg && hasError { - reLines := regexp.MustCompile(`(?s)(^.*ERROR.*)`) + reLines := regexp.MustCompile(`(?m)(^.*ERROR.*$)`) errorLines := reLines.FindAll(contents, -1) - ts.Fatalf("ERRORs found in %s (%s)\n", logFile, errorLines) + var lines []string + for _, line := range errorLines { + lines = append(lines, string(line)) + } + ts.Fatalf("ERRORs found in %s (%s)\n", logFile, strings.Join(lines, "\n")) } if !neg && !hasError { ts.Fatalf("ERRORs not found in %s\n", logFile)