From e5ae1afdbea69b4c2afdf9098f558dd24d543923 Mon Sep 17 00:00:00 2001 From: jt-dd <112463504+jt-dd@users.noreply.github.com> Date: Fri, 15 Nov 2024 11:18:47 +0100 Subject: [PATCH] Fix linter issue (#291) * bump golangci lint version * bumping golangci to latest version --- .github/workflows/linter.yml | 2 +- .golangci.yml | 6 ++---- Dockerfile | 2 +- pkg/collector/k8s_api.go | 2 +- pkg/collector/k8s_api_test.go | 8 -------- pkg/config/config_test.go | 1 - pkg/dump/ingestor_test.go | 3 +-- pkg/dump/pipeline/cluster_role_binding_ingest_test.go | 1 - pkg/dump/pipeline/cluster_role_ingest_test.go | 1 - pkg/dump/pipeline/endpoint_ingest_test.go | 1 - pkg/dump/pipeline/node_ingest_test.go | 1 - pkg/dump/pipeline/pipeline.go | 2 -- pkg/dump/pipeline/pipeline_test.go | 1 - pkg/dump/pipeline/pod_ingest_test.go | 1 - pkg/dump/pipeline/role_binding_ingest_test.go | 1 - pkg/dump/pipeline/role_ingest_test.go | 1 - pkg/dump/result_test.go | 4 ---- pkg/ingestor/api/api_test.go | 2 -- pkg/ingestor/puller/blob/blob_test.go | 5 ----- pkg/ingestor/puller/puller_test.go | 4 ---- pkg/kubehound/graph/builder.go | 3 --- pkg/kubehound/graph/vertex/container_test.go | 1 - pkg/kubehound/graph/vertex/identity_test.go | 1 - pkg/kubehound/graph/vertex/node_test.go | 1 - pkg/kubehound/graph/vertex/permission_set_test.go | 1 - pkg/kubehound/graph/vertex/pod_test.go | 1 - pkg/kubehound/graph/vertex/volume_test.go | 1 - pkg/kubehound/libkube/address_test.go | 1 - pkg/kubehound/storage/cache/memcache_test.go | 2 -- pkg/kubehound/storage/cache/result_test.go | 5 ----- pkg/kubehound/storage/storedb/mongo_writer_test.go | 2 -- pkg/telemetry/log/fields.go | 6 +++--- pkg/telemetry/log/kv.go | 4 ++-- 33 files changed, 11 insertions(+), 67 deletions(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 13f015ac1..57cfbd52e 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -41,5 +41,5 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc with: - version: v1.60 + version: v1.62.0 args: ./... diff --git a/.golangci.yml b/.golangci.yml index bca4771bb..f9c82f541 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -13,6 +13,7 @@ linters: - bodyclose - containedctx - contextcheck + - copyloopvar # - cyclop - decorder - dogsled @@ -22,10 +23,8 @@ linters: - errchkjson - errname - errorlint - - execinquery - exhaustive # - exhaustruct - - exportloopref - forbidigo - forcetypeassert # - gci @@ -41,7 +40,6 @@ linters: # - gofumpt - goheader - goimports - - gomnd - gomoddirectives - gomodguard - goprintffuncname @@ -89,4 +87,4 @@ linters: - usestdlibvars - wastedassign # - whitespace - # - wrapcheck #TODO: add it back later potentially? \ No newline at end of file + # - wrapcheck #TODO: add it back later potentially? diff --git a/Dockerfile b/Dockerfile index 5bda9f976..0f3a7bae7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ ARG GO_VERSION=1.23.0 ARG XX_VERSION=1.2.1 -ARG GOLANGCI_LINT_VERSION=v1.55.2 +ARG GOLANGCI_LINT_VERSION=v1.62.0 # xx is a helper for cross-compilation FROM --platform=${BUILDPLATFORM} tonistiigi/xx:${XX_VERSION} AS xx diff --git a/pkg/collector/k8s_api.go b/pkg/collector/k8s_api.go index ac88dbc6c..d6796a88e 100644 --- a/pkg/collector/k8s_api.go +++ b/pkg/collector/k8s_api.go @@ -230,7 +230,7 @@ func (c *k8sAPICollector) computeMetrics(ctx context.Context) (Metrics, error) { errMetric = errors.Join(errMetric, err) l.Error("could not send gauge", log.ErrorField(err)) } - l.Info("Stats for the run time duration", log.Dur("run", runDuration), log.Dur("wait", runTotalWaitTime), log.Percent("throttling_percent", 100*runThrottlingPercentage, 100)) //nolint:gomnd + l.Info("Stats for the run time duration", log.Dur("run", runDuration), log.Dur("wait", runTotalWaitTime), log.Percent("throttling_percent", 100*runThrottlingPercentage, 100)) // SaveMetadata metadata := Metrics{ diff --git a/pkg/collector/k8s_api_test.go b/pkg/collector/k8s_api_test.go index ad4900910..3c44d6a61 100644 --- a/pkg/collector/k8s_api_test.go +++ b/pkg/collector/k8s_api_test.go @@ -78,7 +78,6 @@ func TestNewK8sAPICollectorConfig(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() v := viper.New() @@ -157,7 +156,6 @@ func Test_k8sAPICollector_streamPodsNamespace(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() clientset, mock := tt.testfct(t) @@ -226,7 +224,6 @@ func Test_k8sAPICollector_StreamRoles(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() clientset, mock := tt.testfct(t) @@ -295,7 +292,6 @@ func Test_k8sAPICollector_StreamRoleBindings(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() clientset, mock := tt.testfct(t) @@ -364,7 +360,6 @@ func Test_k8sAPICollector_StreamNodes(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() clientset, mock := tt.testfct(t) @@ -433,7 +428,6 @@ func Test_k8sAPICollector_StreamClusterRoles(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() clientset, mock := tt.testfct(t) @@ -502,7 +496,6 @@ func Test_k8sAPICollector_StreamClusterRoleBindings(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() clientset, mock := tt.testfct(t) @@ -571,7 +564,6 @@ func Test_k8sAPICollector_StreamEndpoints(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() clientset, mock := tt.testfct(t) diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index ca4998b8c..22d1b7cce 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -177,7 +177,6 @@ func TestMustLoadConfig(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() v := viper.New() diff --git a/pkg/dump/ingestor_test.go b/pkg/dump/ingestor_test.go index 1b81c2690..4d53b3225 100644 --- a/pkg/dump/ingestor_test.go +++ b/pkg/dump/ingestor_test.go @@ -69,7 +69,7 @@ func TestNewDumpIngestor(t *testing.T) { //nolint:paralleltest,nolintlint // Can not run parallel tests as the environment variable KUBECONFIG is set // t.Setenv is not compatible with parallel tests for _, tt := range tests { //nolint:paralleltest - tt := tt + t.Run(tt.name, func(t *testing.T) { got, err := NewDumpIngestor(ctx, tt.args.collectorClient, tt.args.compression, tt.args.directoryOutput, tt.args.runID) if (err != nil) != tt.wantErr { @@ -127,7 +127,6 @@ func TestDumpIngestor_DumpK8sObjects(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() mDumpWriter, mCollectorClient := tt.testfct(t) diff --git a/pkg/dump/pipeline/cluster_role_binding_ingest_test.go b/pkg/dump/pipeline/cluster_role_binding_ingest_test.go index c744902a8..e43b4577d 100644 --- a/pkg/dump/pipeline/cluster_role_binding_ingest_test.go +++ b/pkg/dump/pipeline/cluster_role_binding_ingest_test.go @@ -77,7 +77,6 @@ func TestDumpIngestor_IngestClusterRoleBinding(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() ingestor := tt.testfct(t, tt.args.clusterRoleBinding) diff --git a/pkg/dump/pipeline/cluster_role_ingest_test.go b/pkg/dump/pipeline/cluster_role_ingest_test.go index ec6c57aeb..5184c6f2b 100644 --- a/pkg/dump/pipeline/cluster_role_ingest_test.go +++ b/pkg/dump/pipeline/cluster_role_ingest_test.go @@ -77,7 +77,6 @@ func TestDumpIngestor_IngestClusterRole(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() ingestor := tt.testfct(t, tt.args.clusterRoles) diff --git a/pkg/dump/pipeline/endpoint_ingest_test.go b/pkg/dump/pipeline/endpoint_ingest_test.go index 3bce4897b..972ef3ef3 100644 --- a/pkg/dump/pipeline/endpoint_ingest_test.go +++ b/pkg/dump/pipeline/endpoint_ingest_test.go @@ -82,7 +82,6 @@ func TestDumpIngestor_IngestEndpoint(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() ingestor := tt.testfct(t, tt.args.endpoints) diff --git a/pkg/dump/pipeline/node_ingest_test.go b/pkg/dump/pipeline/node_ingest_test.go index fc6c0c4c5..845eadfec 100644 --- a/pkg/dump/pipeline/node_ingest_test.go +++ b/pkg/dump/pipeline/node_ingest_test.go @@ -78,7 +78,6 @@ func TestDumpIngestor_IngestNode(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() ingestor := tt.testfct(t, tt.args.nodes) diff --git a/pkg/dump/pipeline/pipeline.go b/pkg/dump/pipeline/pipeline.go index 5b388dfb9..6de6eff0b 100644 --- a/pkg/dump/pipeline/pipeline.go +++ b/pkg/dump/pipeline/pipeline.go @@ -140,7 +140,6 @@ func NewPipelineDumpIngestor(ctx context.Context, collector collector.CollectorC func (p *PipelineDumpIngestor) Run(ctx context.Context) error { var err error for _, v := range p.sequence { - v := v p.wp.Submit(func() error { errDump := dumpK8sObjs(ctx, v.operationName, v.entity, v.streamFunc) if errDump != nil { @@ -161,7 +160,6 @@ func (p *PipelineDumpIngestor) WaitAndClose(ctx context.Context) error { } for _, v := range p.closingSequence { - v := v errDump := dumpK8sObjs(ctx, v.operationName, v.entity, v.streamFunc) if errDump != nil { err = errors.Join(err, errDump) diff --git a/pkg/dump/pipeline/pipeline_test.go b/pkg/dump/pipeline/pipeline_test.go index 4a0fdb11e..ffff6ca42 100644 --- a/pkg/dump/pipeline/pipeline_test.go +++ b/pkg/dump/pipeline/pipeline_test.go @@ -159,7 +159,6 @@ func TestPipelineDumpIngestor_Run(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() mDumpWriter, mCollectorClient := tt.testfct(t) diff --git a/pkg/dump/pipeline/pod_ingest_test.go b/pkg/dump/pipeline/pod_ingest_test.go index 1a48724a4..656ebfff8 100644 --- a/pkg/dump/pipeline/pod_ingest_test.go +++ b/pkg/dump/pipeline/pod_ingest_test.go @@ -82,7 +82,6 @@ func TestDumpIngestor_IngestPod(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() ingestor := tt.testfct(t, tt.args.pods) diff --git a/pkg/dump/pipeline/role_binding_ingest_test.go b/pkg/dump/pipeline/role_binding_ingest_test.go index 28ebefe40..13b788ea2 100644 --- a/pkg/dump/pipeline/role_binding_ingest_test.go +++ b/pkg/dump/pipeline/role_binding_ingest_test.go @@ -82,7 +82,6 @@ func TestDumpIngestor_IngestRoleBinding(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() ingestor := tt.testfct(t, tt.args.roleBindings) diff --git a/pkg/dump/pipeline/role_ingest_test.go b/pkg/dump/pipeline/role_ingest_test.go index 125cd23e7..8a16226bc 100644 --- a/pkg/dump/pipeline/role_ingest_test.go +++ b/pkg/dump/pipeline/role_ingest_test.go @@ -82,7 +82,6 @@ func TestDumpIngestor_IngestRole(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() ingestor := tt.testfct(t, tt.args.roles) diff --git a/pkg/dump/result_test.go b/pkg/dump/result_test.go index 88d35e748..7ad489b2f 100644 --- a/pkg/dump/result_test.go +++ b/pkg/dump/result_test.go @@ -86,7 +86,6 @@ func TestParsePath(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() got, err := ParsePath(context.TODO(), tt.args.path) @@ -138,7 +137,6 @@ func TestDumpResult_GetFilename(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() i := &DumpResult{ @@ -192,7 +190,6 @@ func TestDumpResult_GetFullPath(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() i := &DumpResult{ @@ -282,7 +279,6 @@ func TestNewDumpResult(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() got, err := NewDumpResult(tt.args.clusterName, tt.args.runID, tt.args.isCompressed) diff --git a/pkg/ingestor/api/api_test.go b/pkg/ingestor/api/api_test.go index c14f97225..d4fa6fe71 100644 --- a/pkg/ingestor/api/api_test.go +++ b/pkg/ingestor/api/api_test.go @@ -133,7 +133,6 @@ func TestIngestorAPI_Ingest(t *testing.T) { // }, } for _, tt := range tests { - tt := tt mt.Run(tt.name, func(mt *mtest.T) { mt.Parallel() mockedPuller := mocksPuller.NewDataPuller(t) @@ -224,7 +223,6 @@ func TestIngestorAPI_isAlreadyIngestedInDB(t *testing.T) { }, } for _, tt := range tests { - tt := tt mt.Run(tt.name, func(mt *mtest.T) { mt.Parallel() g := &IngestorAPI{ diff --git a/pkg/ingestor/puller/blob/blob_test.go b/pkg/ingestor/puller/blob/blob_test.go index aef9f1765..55004725f 100644 --- a/pkg/ingestor/puller/blob/blob_test.go +++ b/pkg/ingestor/puller/blob/blob_test.go @@ -175,7 +175,6 @@ func TestBlobStore_ListFiles(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() ctx := context.Background() @@ -280,7 +279,6 @@ func TestBlobStore_Pull(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() ctx := context.Background() @@ -374,7 +372,6 @@ func TestNewBlobStorage(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() got, err := NewBlobStorage(tt.args.cfg, tt.args.blobConfig) @@ -451,7 +448,6 @@ func TestBlobStore_Put(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() ctx := context.Background() @@ -515,7 +511,6 @@ func TestBlobStore_Extract(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() ctx := context.Background() diff --git a/pkg/ingestor/puller/puller_test.go b/pkg/ingestor/puller/puller_test.go index 235ae5a38..22ec23bac 100644 --- a/pkg/ingestor/puller/puller_test.go +++ b/pkg/ingestor/puller/puller_test.go @@ -30,7 +30,6 @@ func Test_sanitizeExtractPath(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() if err := sanitizeExtractPath(tt.args.filePath, tt.args.destination); (err != nil) != tt.wantErr { @@ -83,7 +82,6 @@ func TestCheckSanePath(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() if err := CheckSanePath(tt.args.path, tt.args.baseFolder); (err != nil) != tt.wantErr { @@ -124,7 +122,6 @@ func TestExtractTarGz(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() tmpPath, err := os.MkdirTemp("/tmp", "kubehound-test") @@ -195,7 +192,6 @@ func TestIsTarGz(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() got, err := IsTarGz(context.TODO(), tt.args.filePath, tt.args.maxArchiveSize) diff --git a/pkg/kubehound/graph/builder.go b/pkg/kubehound/graph/builder.go index 2cb89827c..1f89e7a1f 100644 --- a/pkg/kubehound/graph/builder.go +++ b/pkg/kubehound/graph/builder.go @@ -126,9 +126,6 @@ func (b *Builder) buildSimple(ctx context.Context, oic *converter.ObjectIDConver } for label, e := range b.edges.Simple() { - e := e - label := label - wp.Submit(func() error { err := b.buildEdge(workCtx, label, e, oic) if err != nil { diff --git a/pkg/kubehound/graph/vertex/container_test.go b/pkg/kubehound/graph/vertex/container_test.go index 7e9096581..66482afd6 100644 --- a/pkg/kubehound/graph/vertex/container_test.go +++ b/pkg/kubehound/graph/vertex/container_test.go @@ -44,7 +44,6 @@ func TestContainer_Traversal(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() v := Container{} diff --git a/pkg/kubehound/graph/vertex/identity_test.go b/pkg/kubehound/graph/vertex/identity_test.go index 03fd664c6..db3387ffc 100644 --- a/pkg/kubehound/graph/vertex/identity_test.go +++ b/pkg/kubehound/graph/vertex/identity_test.go @@ -33,7 +33,6 @@ func TestIdentity_Traversal(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() v := Identity{} diff --git a/pkg/kubehound/graph/vertex/node_test.go b/pkg/kubehound/graph/vertex/node_test.go index 2cecd75af..890e45a4b 100644 --- a/pkg/kubehound/graph/vertex/node_test.go +++ b/pkg/kubehound/graph/vertex/node_test.go @@ -34,7 +34,6 @@ func TestNode_Traversal(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() v := Node{} diff --git a/pkg/kubehound/graph/vertex/permission_set_test.go b/pkg/kubehound/graph/vertex/permission_set_test.go index e29200781..a03b1b94d 100644 --- a/pkg/kubehound/graph/vertex/permission_set_test.go +++ b/pkg/kubehound/graph/vertex/permission_set_test.go @@ -33,7 +33,6 @@ func TestPermissionSet_Traversal(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() v := PermissionSet{} diff --git a/pkg/kubehound/graph/vertex/pod_test.go b/pkg/kubehound/graph/vertex/pod_test.go index fa22a9832..4ea993396 100644 --- a/pkg/kubehound/graph/vertex/pod_test.go +++ b/pkg/kubehound/graph/vertex/pod_test.go @@ -37,7 +37,6 @@ func TestPod_Traversal(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() v := Pod{} diff --git a/pkg/kubehound/graph/vertex/volume_test.go b/pkg/kubehound/graph/vertex/volume_test.go index fe971ab54..e41dc800e 100644 --- a/pkg/kubehound/graph/vertex/volume_test.go +++ b/pkg/kubehound/graph/vertex/volume_test.go @@ -32,7 +32,6 @@ func TestVolume_Traversal(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() v := Volume{} diff --git a/pkg/kubehound/libkube/address_test.go b/pkg/kubehound/libkube/address_test.go index b7a8fc1bd..3a9fa8752 100644 --- a/pkg/kubehound/libkube/address_test.go +++ b/pkg/kubehound/libkube/address_test.go @@ -45,7 +45,6 @@ func TestAddressType(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/kubehound/storage/cache/memcache_test.go b/pkg/kubehound/storage/cache/memcache_test.go index 7106ecb99..6bca20534 100644 --- a/pkg/kubehound/storage/cache/memcache_test.go +++ b/pkg/kubehound/storage/cache/memcache_test.go @@ -61,7 +61,6 @@ func TestMemCacheProvider_Get(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() m := &MemCacheProvider{ @@ -152,7 +151,6 @@ func TestMemCacheAsyncWriter_Queue(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() m := &MemCacheAsyncWriter{ diff --git a/pkg/kubehound/storage/cache/result_test.go b/pkg/kubehound/storage/cache/result_test.go index 7d54de853..3ac416236 100644 --- a/pkg/kubehound/storage/cache/result_test.go +++ b/pkg/kubehound/storage/cache/result_test.go @@ -70,7 +70,6 @@ func TestCacheResult_ObjectID(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() r := &CacheResult{ @@ -142,7 +141,6 @@ func TestCacheResult_Int64(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() r := &CacheResult{ @@ -213,7 +211,6 @@ func TestCacheResult_Text(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() r := &CacheResult{ @@ -284,7 +281,6 @@ func TestCacheResult_Bool(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -370,7 +366,6 @@ func TestCacheResult_Role(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() r := &CacheResult{ diff --git a/pkg/kubehound/storage/storedb/mongo_writer_test.go b/pkg/kubehound/storage/storedb/mongo_writer_test.go index 61fb133df..40b2974f5 100644 --- a/pkg/kubehound/storage/storedb/mongo_writer_test.go +++ b/pkg/kubehound/storage/storedb/mongo_writer_test.go @@ -103,7 +103,6 @@ func TestMongoAsyncWriter_Queue(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() writer := NewMongoAsyncWriter(ctx, db, collections.FakeCollection{}, WithTags([]string{tag.Storage("mongotest")})) @@ -223,7 +222,6 @@ func TestMongoAsyncWriter_Flush(t *testing.T) { t.Cleanup(cleanup) for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/pkg/telemetry/log/fields.go b/pkg/telemetry/log/fields.go index 07fec0f4d..1fe25af7d 100644 --- a/pkg/telemetry/log/fields.go +++ b/pkg/telemetry/log/fields.go @@ -122,10 +122,10 @@ type msec time.Duration func (f msec) String() string { ms := time.Duration(f) / time.Millisecond - if ms < 10 { //nolint: gomnd + if ms < 10 { us := time.Duration(f) / time.Microsecond - return fmt.Sprintf("%0.1fms", float64(us)/1000.0) //nolint: gomnd + return fmt.Sprintf("%0.1fms", float64(us)/1000.0) } return strconv.Itoa(int(ms)) + "ms" @@ -453,7 +453,7 @@ type pct struct { } func (p pct) String() string { - return fmt.Sprintf("%0.3f%%", (p.part/p.whole)*100) //nolint: gomnd + return fmt.Sprintf("%0.3f%%", (p.part/p.whole)*100) } // Percent writes out a percent out of 100%. diff --git a/pkg/telemetry/log/kv.go b/pkg/telemetry/log/kv.go index 523cba161..17633715f 100644 --- a/pkg/telemetry/log/kv.go +++ b/pkg/telemetry/log/kv.go @@ -198,9 +198,9 @@ func (enc *kvEncoder) AppendDuration(value time.Duration) { func (enc *kvEncoder) AppendComplex128(value complex128) { enc.addElementSeparator() r, i := float64(real(value)), float64(imag(value)) - enc.buf.AppendFloat(r, 64) //nolint: gomnd + enc.buf.AppendFloat(r, 64) enc.buf.AppendByte('+') - enc.buf.AppendFloat(i, 64) //nolint: gomnd + enc.buf.AppendFloat(i, 64) enc.buf.AppendByte('i') }