From cc8ff015b4429827057f0db6c6f0b4d0d38fa1d7 Mon Sep 17 00:00:00 2001 From: Dmitrii Stepanov Date: Mon, 20 Mar 2023 09:39:44 +0300 Subject: [PATCH] [#148] linter: Add containedctx linter Context has to be passed as an argument: https://pkg.go.dev/context Signed-off-by: Dmitrii Stepanov --- .golangci.yml | 1 + cmd/frostfs-node/config.go | 1 + cmd/frostfs-node/container.go | 1 + cmd/frostfs-node/reputation/common/util.go | 1 + cmd/frostfs-node/reputation/internal/client/client.go | 1 + pkg/core/storagegroup/storagegroup.go | 2 ++ pkg/innerring/internal/client/prm.go | 1 + pkg/morph/client/constructor.go | 1 + pkg/services/audit/auditor/context.go | 1 + pkg/services/audit/task.go | 1 + pkg/services/container/announcement/load/controller/calls.go | 1 + pkg/services/container/announcement/load/route/calls.go | 1 + pkg/services/object/delete/exec.go | 1 + pkg/services/object/get/exec.go | 1 + pkg/services/object/internal/client/client.go | 1 + pkg/services/object/put/remote.go | 1 + pkg/services/object/put/streamer.go | 1 + pkg/services/object/search/exec.go | 1 + pkg/services/policer/check.go | 1 + pkg/services/reputation/eigentrust/controller/calls.go | 1 + pkg/services/reputation/eigentrust/iteration.go | 1 + pkg/services/reputation/local/controller/calls.go | 1 + 22 files changed, 23 insertions(+) diff --git a/.golangci.yml b/.golangci.yml index 4c4fccc9..f4eed767 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -53,5 +53,6 @@ linters: - predeclared - reassign - whitespace + - containedctx disable-all: true fast: false diff --git a/cmd/frostfs-node/config.go b/cmd/frostfs-node/config.go index 3aabb63d..b2b12241 100644 --- a/cmd/frostfs-node/config.go +++ b/cmd/frostfs-node/config.go @@ -297,6 +297,7 @@ func (a *applicationConfiguration) readConfig(c *config.Config) error { // the application life cycle. // It should not contain any read configuration values, component-specific // helpers and fields. +// nolint: containedctx type internals struct { ctx context.Context ctxCancel func() diff --git a/cmd/frostfs-node/container.go b/cmd/frostfs-node/container.go index bfa555db..ac049922 100644 --- a/cmd/frostfs-node/container.go +++ b/cmd/frostfs-node/container.go @@ -363,6 +363,7 @@ func (p *remoteLoadAnnounceWriterProvider) InitWriter(ctx context.Context) (load }, nil } +// nolint: containedctx type remoteLoadAnnounceWriter struct { ctx context.Context diff --git a/cmd/frostfs-node/reputation/common/util.go b/cmd/frostfs-node/reputation/common/util.go index c0a5cbc7..28351d0c 100644 --- a/cmd/frostfs-node/reputation/common/util.go +++ b/cmd/frostfs-node/reputation/common/util.go @@ -8,6 +8,7 @@ import ( ) // EpochContext is a std context extended with epoch data. +// nolint: containedctx type EpochContext struct { context.Context E uint64 diff --git a/cmd/frostfs-node/reputation/internal/client/client.go b/cmd/frostfs-node/reputation/internal/client/client.go index 79bc3d44..22fd21d4 100644 --- a/cmd/frostfs-node/reputation/internal/client/client.go +++ b/cmd/frostfs-node/reputation/internal/client/client.go @@ -9,6 +9,7 @@ import ( "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/reputation" ) +// nolint: containedctx type commonPrm struct { cli coreclient.Client diff --git a/pkg/core/storagegroup/storagegroup.go b/pkg/core/storagegroup/storagegroup.go index 6474377b..f4e58413 100644 --- a/pkg/core/storagegroup/storagegroup.go +++ b/pkg/core/storagegroup/storagegroup.go @@ -11,6 +11,7 @@ import ( ) // SearchSGPrm groups the parameters which are formed by Processor to search the storage group objects. +// nolint: containedctx type SearchSGPrm struct { Context context.Context @@ -25,6 +26,7 @@ type SearchSGDst struct { } // GetSGPrm groups parameter of GetSG operation. +// nolint: containedctx type GetSGPrm struct { Context context.Context diff --git a/pkg/innerring/internal/client/prm.go b/pkg/innerring/internal/client/prm.go index 3c749fe6..5498eb37 100644 --- a/pkg/innerring/internal/client/prm.go +++ b/pkg/innerring/internal/client/prm.go @@ -6,6 +6,7 @@ import ( oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id" ) +// nolint: containedctx type contextPrm struct { ctx context.Context } diff --git a/pkg/morph/client/constructor.go b/pkg/morph/client/constructor.go index 01fd30f7..efb3d0bf 100644 --- a/pkg/morph/client/constructor.go +++ b/pkg/morph/client/constructor.go @@ -26,6 +26,7 @@ type Option func(*cfg) type Callback func() // groups the configurations with default values. +// nolint: containedctx type cfg struct { ctx context.Context // neo-go client context diff --git a/pkg/services/audit/auditor/context.go b/pkg/services/audit/auditor/context.go index 528a3bbb..4a5cbb45 100644 --- a/pkg/services/audit/auditor/context.go +++ b/pkg/services/audit/auditor/context.go @@ -81,6 +81,7 @@ type ContextPrm struct { pdpWorkerPool, porWorkerPool util.WorkerPool } +// nolint: containedctx type commonCommunicatorPrm struct { Context context.Context diff --git a/pkg/services/audit/task.go b/pkg/services/audit/task.go index 554aab6c..35932a69 100644 --- a/pkg/services/audit/task.go +++ b/pkg/services/audit/task.go @@ -10,6 +10,7 @@ import ( ) // Task groups groups the container audit parameters. +// nolint: containedctx type Task struct { reporter Reporter diff --git a/pkg/services/container/announcement/load/controller/calls.go b/pkg/services/container/announcement/load/controller/calls.go index 54eb7e07..c6b574c3 100644 --- a/pkg/services/container/announcement/load/controller/calls.go +++ b/pkg/services/container/announcement/load/controller/calls.go @@ -15,6 +15,7 @@ type StartPrm struct { Epoch uint64 } +// nolint: containedctx type commonContext struct { epoch uint64 diff --git a/pkg/services/container/announcement/load/route/calls.go b/pkg/services/container/announcement/load/route/calls.go index 989120b4..95099fd5 100644 --- a/pkg/services/container/announcement/load/route/calls.go +++ b/pkg/services/container/announcement/load/route/calls.go @@ -10,6 +10,7 @@ import ( "go.uber.org/zap" ) +// nolint: containedctx type routeContext struct { context.Context diff --git a/pkg/services/object/delete/exec.go b/pkg/services/object/delete/exec.go index 112796f2..4da4c808 100644 --- a/pkg/services/object/delete/exec.go +++ b/pkg/services/object/delete/exec.go @@ -18,6 +18,7 @@ type statusError struct { err error } +// nolint: containedctx type execCtx struct { svc *Service diff --git a/pkg/services/object/get/exec.go b/pkg/services/object/get/exec.go index 09ff9a82..9858b32b 100644 --- a/pkg/services/object/get/exec.go +++ b/pkg/services/object/get/exec.go @@ -19,6 +19,7 @@ type statusError struct { err error } +// nolint: containedctx type execCtx struct { svc *Service diff --git a/pkg/services/object/internal/client/client.go b/pkg/services/object/internal/client/client.go index 8f2483bc..ee6777a5 100644 --- a/pkg/services/object/internal/client/client.go +++ b/pkg/services/object/internal/client/client.go @@ -18,6 +18,7 @@ import ( "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/session" ) +// nolint: containedctx type commonPrm struct { cli coreclient.Client diff --git a/pkg/services/object/put/remote.go b/pkg/services/object/put/remote.go index 0f0dc355..760de750 100644 --- a/pkg/services/object/put/remote.go +++ b/pkg/services/object/put/remote.go @@ -15,6 +15,7 @@ import ( "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object" ) +// nolint: containedctx type remoteTarget struct { ctx context.Context diff --git a/pkg/services/object/put/streamer.go b/pkg/services/object/put/streamer.go index ae1a2f45..8ca90e86 100644 --- a/pkg/services/object/put/streamer.go +++ b/pkg/services/object/put/streamer.go @@ -16,6 +16,7 @@ import ( "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/user" ) +// nolint: containedctx type Streamer struct { *cfg diff --git a/pkg/services/object/search/exec.go b/pkg/services/object/search/exec.go index 18700b25..a1737b52 100644 --- a/pkg/services/object/search/exec.go +++ b/pkg/services/object/search/exec.go @@ -16,6 +16,7 @@ type statusError struct { err error } +// nolint: containedctx type execCtx struct { svc *Service diff --git a/pkg/services/policer/check.go b/pkg/services/policer/check.go index 1da07f45..e240bbea 100644 --- a/pkg/services/policer/check.go +++ b/pkg/services/policer/check.go @@ -136,6 +136,7 @@ func (p *Policer) processObject(ctx context.Context, addrWithType objectcore.Add } } +// nolint: containedctx type processPlacementContext struct { context.Context diff --git a/pkg/services/reputation/eigentrust/controller/calls.go b/pkg/services/reputation/eigentrust/controller/calls.go index 87d23c7f..28228706 100644 --- a/pkg/services/reputation/eigentrust/controller/calls.go +++ b/pkg/services/reputation/eigentrust/controller/calls.go @@ -12,6 +12,7 @@ type ContinuePrm struct { Epoch uint64 } +// nolint: containedctx type iterContext struct { context.Context diff --git a/pkg/services/reputation/eigentrust/iteration.go b/pkg/services/reputation/eigentrust/iteration.go index 90a214eb..b06064f7 100644 --- a/pkg/services/reputation/eigentrust/iteration.go +++ b/pkg/services/reputation/eigentrust/iteration.go @@ -38,6 +38,7 @@ type IterationTrust struct { // IterContext aggregates context and data required for // iterations. +// nolint: containedctx type IterContext struct { context.Context EpochIteration diff --git a/pkg/services/reputation/local/controller/calls.go b/pkg/services/reputation/local/controller/calls.go index d4e122b0..98815492 100644 --- a/pkg/services/reputation/local/controller/calls.go +++ b/pkg/services/reputation/local/controller/calls.go @@ -51,6 +51,7 @@ type reportContext struct { ctx common.Context } +// nolint: containedctx type iteratorContext struct { context.Context