fix: clear golangci-lint backlog and make lint job blocking
Addresses errcheck, gosec, revive, staticcheck, and unused findings
across the codebase (unchecked error returns, unsafe file inclusion
warnings on operator/test-controlled paths, missing package comments,
unused parameters, deprecated API usage). Also fixes two suppression
comments that were silently no-ops due to wrong syntax (#nosec needs
a leading '#', nolint reasons need '//' not '--').
With the backlog clear, drop continue-on-error from the CI lint job
per the plan left in b4b4806.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -94,7 +94,6 @@ func TestCRITICAL1_MaxSizeEnforcement(t *testing.T) {
|
||||
|
||||
// Send more notifications than max_size
|
||||
notificationCount := 10
|
||||
notificationIDs := make([]string, 0, notificationCount)
|
||||
|
||||
for i := 0; i < notificationCount; i++ {
|
||||
req := client.NotificationRequest{
|
||||
@@ -104,11 +103,10 @@ func TestCRITICAL1_MaxSizeEnforcement(t *testing.T) {
|
||||
Recipients: []string{"test@example.com"},
|
||||
}
|
||||
|
||||
resp, err := suite.Client.Send(ctx, req)
|
||||
_, err := suite.Client.Send(ctx, req)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to send notification %d: %v", i, err)
|
||||
}
|
||||
notificationIDs = append(notificationIDs, resp.NotificationID)
|
||||
}
|
||||
|
||||
t.Logf("Sent %d notifications", notificationCount)
|
||||
@@ -328,7 +326,7 @@ func TestCRITICAL1_MemoryBounded(t *testing.T) {
|
||||
req := client.NotificationRequest{
|
||||
Type: "stdout",
|
||||
Subject: fmt.Sprintf("Batch %d Notif %d", batch, i),
|
||||
Body: fmt.Sprintf("Test data for notification"),
|
||||
Body: "Test data for notification",
|
||||
Recipients: []string{"test@example.com"},
|
||||
}
|
||||
|
||||
@@ -382,7 +380,7 @@ func TestCRITICAL1_ServiceHealthy(t *testing.T) {
|
||||
req := client.NotificationRequest{
|
||||
Type: "stdout",
|
||||
Subject: fmt.Sprintf("Health %d", i),
|
||||
Body: fmt.Sprintf("Test"),
|
||||
Body: "Test",
|
||||
Recipients: []string{"test@example.com"},
|
||||
}
|
||||
|
||||
|
||||
+17
-33
@@ -94,13 +94,17 @@ func SetupSuite(t *testing.T, retention ...string) *TestSuite {
|
||||
// Get container port
|
||||
host, err := container.Host(ctx)
|
||||
if err != nil {
|
||||
container.Terminate(ctx)
|
||||
if termErr := container.Terminate(ctx); termErr != nil {
|
||||
t.Logf("Failed to terminate container during cleanup: %v", termErr)
|
||||
}
|
||||
t.Fatalf("Failed to get container host: %v", err)
|
||||
}
|
||||
|
||||
port, err := container.MappedPort(ctx, "8080")
|
||||
if err != nil {
|
||||
container.Terminate(ctx)
|
||||
if termErr := container.Terminate(ctx); termErr != nil {
|
||||
t.Logf("Failed to terminate container during cleanup: %v", termErr)
|
||||
}
|
||||
t.Fatalf("Failed to get container port: %v", err)
|
||||
}
|
||||
|
||||
@@ -118,7 +122,9 @@ func SetupSuite(t *testing.T, retention ...string) *TestSuite {
|
||||
deadline := time.Now().Add(30 * time.Second)
|
||||
for {
|
||||
if time.Now().After(deadline) {
|
||||
container.Terminate(ctx)
|
||||
if termErr := container.Terminate(ctx); termErr != nil {
|
||||
t.Logf("Failed to terminate container during cleanup: %v", termErr)
|
||||
}
|
||||
t.Fatalf("Service failed to become ready")
|
||||
}
|
||||
|
||||
@@ -141,7 +147,13 @@ func SetupSuite(t *testing.T, retention ...string) *TestSuite {
|
||||
// TeardownSuite stops and removes the container
|
||||
func (s *TestSuite) TeardownSuite(ctx context.Context) {
|
||||
if s.Container != nil {
|
||||
s.Container.Terminate(ctx)
|
||||
if err := s.Container.Terminate(ctx); err != nil {
|
||||
if s.T != nil {
|
||||
s.T.Logf("Failed to terminate container during cleanup: %v", err)
|
||||
} else {
|
||||
fmt.Printf("e2e: failed to terminate container during cleanup: %v\n", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,7 +184,7 @@ func (s *TestSuite) GetLogs(ctx context.Context) string {
|
||||
if err != nil {
|
||||
return fmt.Sprintf("error reading logs: %v", err)
|
||||
}
|
||||
defer reader.Close()
|
||||
defer func() { _ = reader.Close() }()
|
||||
|
||||
logs, err := io.ReadAll(reader)
|
||||
if err != nil {
|
||||
@@ -181,31 +193,3 @@ func (s *TestSuite) GetLogs(ctx context.Context) string {
|
||||
|
||||
return string(logs)
|
||||
}
|
||||
|
||||
// buildTestImage builds the docker image for testing
|
||||
func buildTestImage(t *testing.T) {
|
||||
// Get the project root
|
||||
wd, err := os.Getwd()
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to get working directory: %v", err)
|
||||
}
|
||||
|
||||
// Find the project root by looking for go.mod
|
||||
for {
|
||||
if _, err := os.Stat(filepath.Join(wd, "go.mod")); err == nil {
|
||||
break
|
||||
}
|
||||
parent := filepath.Dir(wd)
|
||||
if parent == wd {
|
||||
t.Fatalf("Could not find project root")
|
||||
}
|
||||
wd = parent
|
||||
}
|
||||
|
||||
// Check if Dockerfile exists
|
||||
dockerfile := filepath.Join(wd, "Dockerfile")
|
||||
if _, err := os.Stat(dockerfile); err != nil {
|
||||
t.Logf("Warning: Dockerfile not found at %s, using generic build", dockerfile)
|
||||
// The container will be built from the binary
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user