From 3799dcc164fa0c47e87c1a9bb0225edec7a893b1 Mon Sep 17 00:00:00 2001 From: Roozbeh Sharifnasab Date: Tue, 19 Nov 2024 14:04:16 +0330 Subject: [PATCH] fix(lint) --- .golangci.yml | 15 +++------------ client.go | 5 ++++- internal/server.go | 2 +- server.go | 8 ++++---- 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index d6a92bf..2aac365 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,6 +1,6 @@ --- -run: - skip-files: +issues: + exclude-files: - ".*_test.go" linters: enable-all: true @@ -9,18 +9,9 @@ linters: # it should improve to support more known patterns - varnamelen # deprecated linters - - varcheck - - deadcode - - nosnakecase - revive - - ifshort - - structcheck - - maligned - - scopelint - - golint - - interfacer - - exhaustivestruct - ireturn - cyclop - wrapcheck - nolintlint + - exportloopref diff --git a/client.go b/client.go index cfe0496..122754a 100644 --- a/client.go +++ b/client.go @@ -90,6 +90,7 @@ func NewClient(address string, topics []string, config *ClientConfig) (Client, e stream, err := connection.OpenUniStream() if err != nil { l.Error("failed to open send stream", zap.Error(err)) + err = internal.CloseClientConnection( connection, internal.CodeFailedToCreateStream, @@ -105,6 +106,7 @@ func NewClient(address string, topics []string, config *ClientConfig) (Client, e err = internal.WriteData(bytes, stream) if err != nil { l.Error("failed to send offer to server", zap.Error(err)) + err = internal.CloseClientConnection( connection, internal.CodeFailedToSendOffer, @@ -122,6 +124,7 @@ func NewClient(address string, topics []string, config *ClientConfig) (Client, e receiveStream, err := connection.AcceptUniStream(context.Background()) if err != nil { l.Error("failed to open receive stream", zap.Error(err)) + err = internal.CloseClientConnection( connection, internal.CodeFailedToCreateStream, @@ -170,7 +173,7 @@ func processConfig(config *ClientConfig) ClientConfig { //nolint:typecheck func reconnect(policy ReconnectPolicy, address string, tlcCfg *tls.Config, l *zap.Logger) (quic.Connection, bool) { - for i := 0; i < policy.RetryTimes; i++ { + for range policy.RetryTimes { connection, err := quic.DialAddr(context.Background(), address, tlcCfg, nil) if err == nil { return connection, true diff --git a/internal/server.go b/internal/server.go index cb62eac..6e4b731 100644 --- a/internal/server.go +++ b/internal/server.go @@ -178,7 +178,7 @@ func SendError(sendStream quic.SendStream, e *Error) error { return WriteData(errEvent, sendStream) } -func CloseClientConnection(connection quic.Connection, code int, err error) error { +func CloseClientConnection(connection quic.Connection, code uint64, err error) error { appCode := quic.ApplicationErrorCode(code) if err = connection.CloseWithError(appCode, err.Error()); err != nil { diff --git a/server.go b/server.go index 1be9002..0f53802 100644 --- a/server.go +++ b/server.go @@ -41,11 +41,11 @@ type MetricConfig struct { type Server interface { Publish(topic string, event []byte) - SetAuthenticator(auth.Authenticator) - SetAuthenticatorFunc(auth.AuthenticatorFunc) + SetAuthenticator(authenticator auth.Authenticator) + SetAuthenticatorFunc(authenticatorFunc auth.AuthenticatorFunc) - SetAuthorizer(auth.Authorizer) - SetAuthorizerFunc(auth.AuthorizerFunc) + SetAuthorizer(authorizer auth.Authorizer) + SetAuthorizerFunc(authorizer auth.AuthorizerFunc) MetricHandler() http.Handler }