From 220691319be49a6937cc9fbb609a5ef745aa7038 Mon Sep 17 00:00:00 2001 From: Soren Yang Date: Mon, 4 Dec 2023 16:56:56 +0800 Subject: [PATCH] chore(*): enable nilerr, unparam linter Signed-off-by: Soren Yang --- .golangci.yaml | 12 ++++++++---- common/logger.go | 1 + coordinator/impl/coordinator.go | 1 + coordinator/impl/k8s_client_test.go | 1 + coordinator/impl/metadata_test.go | 4 ++-- server/wal/wal_rw_segment.go | 1 + 6 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index 84127bec..3893defb 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -40,14 +40,14 @@ linters: # - gomoddirectives # - gosec - nakedret - # - nilerr + - nilerr # - nilnil # - noctx - nolintlint - prealloc - predeclared - promlinter - # - reassign + - reassign - rowserrcheck - sqlclosecheck - tenv @@ -55,7 +55,7 @@ linters: # - thelper - tparallel - unconvert - # - unparam + - unparam - usestdlibvars - wastedassign @@ -66,4 +66,8 @@ linters-settings: ignore-tests: true issues: - fix: true \ No newline at end of file + fix: true + exclude-rules: + - path: _test\.go + linters: + - unparam \ No newline at end of file diff --git a/common/logger.go b/common/logger.go index db84fe92..d83f3aa0 100644 --- a/common/logger.go +++ b/common/logger.go @@ -57,6 +57,7 @@ func ParseLogLevel(levelStr string) (slog.Level, error) { func ConfigureLogger() { zerolog.TimeFieldFormat = time.RFC3339Nano + //nolint zerolog.ErrorStackMarshaler = pkgerrors.MarshalStack protoMarshal := protojson.MarshalOptions{ diff --git a/coordinator/impl/coordinator.go b/coordinator/impl/coordinator.go index 6c0b140a..c8dfd800 100644 --- a/coordinator/impl/coordinator.go +++ b/coordinator/impl/coordinator.go @@ -443,6 +443,7 @@ func (c *coordinator) handleClusterConfigUpdated() error { return nil } +//nolint:unparam func (c *coordinator) rebalanceCluster() error { c.Lock() actions := rebalanceCluster(c.ClusterConfig.Servers, c.clusterStatus) diff --git a/coordinator/impl/k8s_client_test.go b/coordinator/impl/k8s_client_test.go index 03ca7188..33e947f9 100644 --- a/coordinator/impl/k8s_client_test.go +++ b/coordinator/impl/k8s_client_test.go @@ -38,6 +38,7 @@ func K8SResourceVersionSupport(tracker testing.ObjectTracker) testing.ReactionFu objMeta := accessor(action.GetObject()) existing, err := tracker.Get(gvr, ns, objMeta.GetName()) if err != nil { + //nolint:nilerr return false, action.GetObject(), nil } existingObjMeta := accessor(existing) diff --git a/coordinator/impl/metadata_test.go b/coordinator/impl/metadata_test.go index 84be6678..f2771ffa 100644 --- a/coordinator/impl/metadata_test.go +++ b/coordinator/impl/metadata_test.go @@ -31,13 +31,13 @@ var ( return f }() metadataProviders = map[string]func(t *testing.T) MetadataProvider{ - "memory": func(t *testing.T) MetadataProvider { + "memory": func(_ *testing.T) MetadataProvider { return NewMetadataProviderMemory() }, "file": func(t *testing.T) MetadataProvider { return NewMetadataProviderFile(filepath.Join(t.TempDir(), "metadata")) }, - "configmap": func(t *testing.T) MetadataProvider { + "configmap": func(_ *testing.T) MetadataProvider { return NewMetadataProviderConfigMap(_fake, "ns", "n") }, } diff --git a/server/wal/wal_rw_segment.go b/server/wal/wal_rw_segment.go index 2b4dc244..8c9ae134 100644 --- a/server/wal/wal_rw_segment.go +++ b/server/wal/wal_rw_segment.go @@ -148,6 +148,7 @@ func (ms *readWriteSegment) Flush() error { return ms.txnMappedFile.Flush() } +//nolint:unparam func (ms *readWriteSegment) rebuildIdx() error { // Scan the mapped file and rebuild the index