From 57aec15a5044b060f6d6cd84f984d4ce8c0b17e3 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Thu, 9 Jan 2025 22:42:53 +0100 Subject: [PATCH] chore: enable unnecessary-stmt rule from revive Signed-off-by: Matthieu MOREL --- client/pkg/types/urls.go | 1 - server/etcdmain/etcd.go | 3 +-- server/storage/wal/repair.go | 3 +-- tools/.golangci.yaml | 37 ++++++++++-------------------------- 4 files changed, 12 insertions(+), 32 deletions(-) diff --git a/client/pkg/types/urls.go b/client/pkg/types/urls.go index 49a38967e64..7dca16c0482 100644 --- a/client/pkg/types/urls.go +++ b/client/pkg/types/urls.go @@ -47,7 +47,6 @@ func NewURLs(strs []string) (URLs, error) { return nil, fmt.Errorf("URL must not contain a path: %s", in) } case "unix", "unixs": - break default: return nil, fmt.Errorf("URL scheme must be http, https, unix, or unixs: %s", in) } diff --git a/server/etcdmain/etcd.go b/server/etcdmain/etcd.go index 16bba3736fd..cb633e7e5d0 100644 --- a/server/etcdmain/etcd.go +++ b/server/etcdmain/etcd.go @@ -64,8 +64,7 @@ func startEtcdOrProxyV2(args []string) { lg.Info("Running: ", zap.Strings("args", args)) if err != nil { lg.Warn("failed to verify flags", zap.Error(err)) - switch { - case errorspkg.Is(err, embed.ErrUnsetAdvertiseClientURLsFlag): + if errorspkg.Is(err, embed.ErrUnsetAdvertiseClientURLsFlag) { lg.Warn("advertise client URLs are not set", zap.Error(err)) } os.Exit(1) diff --git a/server/storage/wal/repair.go b/server/storage/wal/repair.go index 16277540f34..f8f814f0449 100644 --- a/server/storage/wal/repair.go +++ b/server/storage/wal/repair.go @@ -49,8 +49,7 @@ func Repair(lg *zap.Logger, dirpath string) bool { switch { case err == nil: // update crc of the decoder when necessary - switch rec.Type { - case CrcType: + if rec.Type == CrcType { crc := decoder.LastCRC() // current crc of decoder must match the crc of the record. // do no need to match 0 crc, since the decoder is a new one at this case. diff --git a/tools/.golangci.yaml b/tools/.golangci.yaml index 3ea8ab82302..a03525eaeb6 100644 --- a/tools/.golangci.yaml +++ b/tools/.golangci.yaml @@ -44,58 +44,41 @@ linters-settings: # please keep this alphabetized # Align with https://github.com/alexkohler/nakedret/blob/v1.0.2/cmd/nakedret/main.go#L10 max-func-lines: 5 revive: - ignore-generated-header: false - severity: error confidence: 0.8 - enable-all-rules: false rules: - name: blank-imports - severity: error disabled: false - name: context-as-argument - severity: error + disabled: false + - name: context-keys-type disabled: false - name: dot-imports - severity: error + disabled: false + - name: error-naming disabled: false - name: error-return - severity: error disabled: false - - name: error-naming - severity: error + - name: error-strings + disabled: false + - name: errorf disabled: false - name: if-return - severity: error disabled: false - name: increment-decrement - severity: error disabled: false - - name: var-declaration - severity: error + - name: indent-error-flow disabled: false - name: package-comments - severity: error disabled: false - name: range - severity: error disabled: false - name: receiver-naming - severity: error disabled: false - name: time-naming - severity: error - disabled: false - - name: indent-error-flow - severity: error - disabled: false - - name: errorf - severity: error disabled: false - - name: context-keys-type - severity: error + - name: unnecessary-stmt disabled: false - - name: error-strings - severity: error + - name: var-declaration disabled: false - name: var-naming disabled: false