@@ -76,14 +76,16 @@ type Config struct {
7676// - Server sends pings; client responds with pongs
7777// - Client also sends pings; server responds with pongs
7878// - Both sides use read timeouts to detect dead connections
79+ //
80+ //nolint:govet // Field alignment optimization would reduce readability
7981type Client struct {
82+ mu sync.RWMutex
83+ config Config
8084 logger * slog.Logger
8185 ws * websocket.Conn
8286 stopCh chan struct {}
8387 stoppedCh chan struct {}
84- config Config
8588 writeCh chan any // Channel for serializing all writes
86- mu sync.RWMutex
8789 eventCount int
8890 retries int
8991}
@@ -231,6 +233,8 @@ func (c *Client) Stop() {
231233}
232234
233235// connect establishes a WebSocket connection and handles events.
236+ //
237+ //nolint:gocognit,funlen,maintidx // Connection lifecycle orchestration is inherently complex
234238func (c * Client ) connect (ctx context.Context ) error {
235239 c .logger .Info ("Establishing WebSocket connection" )
236240
@@ -339,12 +343,21 @@ func (c *Client) connect(ctx context.Context) error {
339343 }
340344
341345 // Check response type
342- responseType , _ := firstResponse [msgTypeField ].(string ) //nolint:errcheck // type assertion, not error
346+ responseType , ok := firstResponse [msgTypeField ].(string )
347+ if ! ok {
348+ responseType = ""
349+ }
343350
344351 // Handle error response
345352 if responseType == "error" {
346- errorCode , _ := firstResponse ["error" ].(string ) //nolint:errcheck // type assertion, not error
347- message , _ := firstResponse ["message" ].(string ) //nolint:errcheck // type assertion, not error
353+ errorCode , ok := firstResponse ["error" ].(string )
354+ if ! ok {
355+ errorCode = ""
356+ }
357+ message , ok := firstResponse ["message" ].(string )
358+ if ! ok {
359+ message = ""
360+ }
348361 c .logger .Error (separatorLine )
349362 c .logger .Error ("SUBSCRIPTION REJECTED BY SERVER!" , "error_code" , errorCode , "message" , message )
350363 c .logger .Error (separatorLine )
@@ -531,7 +544,10 @@ func (c *Client) readEvents(ctx context.Context, ws *websocket.Conn) error {
531544 }
532545
533546 // Check message type
534- responseType , _ := response [msgTypeField ].(string ) //nolint:errcheck // type assertion, not error
547+ responseType , ok := response [msgTypeField ].(string )
548+ if ! ok {
549+ responseType = ""
550+ }
535551
536552 // Handle ping messages from server
537553 if responseType == "ping" {
0 commit comments