Skip to content

Commit d1f198b

Browse files
authored
fix: resolve nil pointer dereference warnings in forward_test.go (minekube#606)
Replace t.Fatal() nil checks with require.NotNil() which the static analyzer understands stops execution, fixing SA5011 warnings.
1 parent a171150 commit d1f198b

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

pkg/edition/java/lite/forward_test.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"errors"
55
"testing"
66

7+
"github.com/stretchr/testify/require"
78
"go.minekube.com/gate/pkg/edition/java/proto/packet"
89
"go.minekube.com/gate/pkg/gate/proto"
910
)
@@ -32,9 +33,7 @@ func TestDecodeStatusResponse_WithErrDecoderLeftBytes(t *testing.T) {
3233
t.Errorf("decodeStatusResponse should ignore ErrDecoderLeftBytes (issue #297), got error: %v", err)
3334
}
3435

35-
if result == nil {
36-
t.Fatal("decodeStatusResponse returned nil result")
37-
}
36+
require.NotNil(t, result, "decodeStatusResponse returned nil result")
3837

3938
// Verify the status response was properly decoded
4039
expectedStatus := `{"version":{"name":"Test","protocol":754},"players":{"online":5,"max":20},"description":"Test Server"}`
@@ -89,9 +88,7 @@ func TestDecodeStatusResponse_Success(t *testing.T) {
8988
t.Errorf("decodeStatusResponse should succeed, got error: %v", err)
9089
}
9190

92-
if result == nil {
93-
t.Fatal("decodeStatusResponse returned nil result")
94-
}
91+
require.NotNil(t, result, "decodeStatusResponse returned nil result")
9592

9693
// Verify the status response
9794
expectedStatus := `{"version":{"name":"Normal","protocol":754},"players":{"online":10,"max":50}}`

0 commit comments

Comments
 (0)