Skip to content

Commit

Permalink
More linting code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
fclairamb committed Mar 3, 2024
1 parent 1dfdf82 commit 7ca9755
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions client_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,28 +463,28 @@ func (c *clientHandler) readCommand() bool {

func (c *clientHandler) handleCommandsStreamError(err error) {
// florent(2018-01-14): #58: IDLE timeout: Adding some code to deal with the deadline
switch err := err.(type) {
case net.Error:
if err.Timeout() {
var errNetError net.Error
if errors.As(err, &errNetError) {
if errNetError.Timeout() {
// We have to extend the deadline now
if err := c.conn.SetDeadline(time.Now().Add(time.Minute)); err != nil {
c.logger.Error("Could not set read deadline", "err", err)
if errSet := c.conn.SetDeadline(time.Now().Add(time.Minute)); errSet != nil {
c.logger.Error("Could not set read deadline", "err", errSet)

Check warning on line 471 in client_handler.go

View check run for this annotation

Codecov / codecov/patch

client_handler.go#L471

Added line #L471 was not covered by tests
}

c.logger.Info("Client IDLE timeout", "err", err)
c.writeMessage(
StatusServiceNotAvailable,
fmt.Sprintf("command timeout (%d seconds): closing control connection", c.server.settings.IdleTimeout))

if err := c.writer.Flush(); err != nil {
c.logger.Error("Flush error", "err", err)
if errFlush := c.writer.Flush(); errFlush != nil {
c.logger.Error("Flush error", "err", errFlush)

Check warning on line 480 in client_handler.go

View check run for this annotation

Codecov / codecov/patch

client_handler.go#L480

Added line #L480 was not covered by tests
}

break
return
}

c.logger.Error("Network error", "err", err)
default:
} else {
if errors.Is(err, io.EOF) {
if c.debug {
c.logger.Debug("Client disconnected", "clean", false)
Expand Down
4 changes: 2 additions & 2 deletions server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func TestServerSettingsIPError(t *testing.T) {
}

err := server.loadSettings()
_, ok := err.(*ipValidationError)
_, ok := err.(*ipValidationError) //nolint:errorlint // Here we want to test the exact error match
require.True(t, ok)
})

Expand All @@ -207,7 +207,7 @@ func TestServerSettingsIPError(t *testing.T) {
}

err := server.loadSettings()
_, ok := err.(*ipValidationError)
_, ok := err.(*ipValidationError) //nolint:errorlint // Here we want to test the exact error match
require.True(t, ok)
})

Expand Down

0 comments on commit 7ca9755

Please sign in to comment.