From 2ff601c46c4c6ebff7baa8ff97be7788e30e7e5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Garc=C3=ADa=20Crespo?= Date: Fri, 2 Feb 2024 10:35:50 +0000 Subject: [PATCH] Remove extra loop var copies --- .golangci.yml | 3 +++ internal/am/delete_transfer_test.go | 1 - internal/am/job_tracker_test.go | 2 -- internal/am/poll_ingest_test.go | 1 - internal/am/poll_transfer_test.go | 1 - internal/am/start_transfer_test.go | 1 - internal/am/upload_transfer_test.go | 1 - internal/package_/status_test.go | 1 - internal/persistence/ent/client/client_test.go | 2 -- internal/sftp/goclient_test.go | 2 -- internal/storage/location_test.go | 6 ------ internal/storage/types/location_config_test.go | 2 -- internal/storage/types/status_test.go | 1 - internal/watcher/watcher.go | 3 --- internal/workflow/activities/bundle_test.go | 1 - internal/workflow/activities/download_test.go | 1 - internal/workflow/activities/zip_test.go | 1 - 17 files changed, 3 insertions(+), 27 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 11334fc9f..1fe5fb0aa 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -42,3 +42,6 @@ linters-settings: exclude-generated: false severity: low confidence: low + govet: + disable: + - loopclosure diff --git a/internal/am/delete_transfer_test.go b/internal/am/delete_transfer_test.go index 678cfe224..4c4d56875 100644 --- a/internal/am/delete_transfer_test.go +++ b/internal/am/delete_transfer_test.go @@ -82,7 +82,6 @@ func TestDeleteTransferActivity(t *testing.T) { errMsg: fmt.Sprintf("delete transfer: path: %q: %v", td.Join(filename), errors.New("SSH: failed to connect: dial tcp 127.0.0.1:2200: connect: connection refused")), }, } { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/internal/am/job_tracker_test.go b/internal/am/job_tracker_test.go index 2e655627c..7fb68e2c2 100644 --- a/internal/am/job_tracker_test.go +++ b/internal/am/job_tracker_test.go @@ -147,7 +147,6 @@ func TestJobTracker(t *testing.T) { wantErr: "invalid Archivematica credentials", }, } { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -270,7 +269,6 @@ func TestConvertJobToPreservationTask(t *testing.T) { want: package_.PreservationTask{}, }, } { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/internal/am/poll_ingest_test.go b/internal/am/poll_ingest_test.go index 504c44d87..aec5eb259 100644 --- a/internal/am/poll_ingest_test.go +++ b/internal/am/poll_ingest_test.go @@ -239,7 +239,6 @@ func TestPollIngestActivity(t *testing.T) { wantErr: "Archivematica resource not found", }, } { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/internal/am/poll_transfer_test.go b/internal/am/poll_transfer_test.go index 43602d0fd..7175c8138 100644 --- a/internal/am/poll_transfer_test.go +++ b/internal/am/poll_transfer_test.go @@ -271,7 +271,6 @@ func TestPollTransferActivity(t *testing.T) { wantErr: "Archivematica resource not found", }, } { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/internal/am/start_transfer_test.go b/internal/am/start_transfer_test.go index 7d98beb8d..588766e1e 100644 --- a/internal/am/start_transfer_test.go +++ b/internal/am/start_transfer_test.go @@ -89,7 +89,6 @@ func TestStartTransferActivity(t *testing.T) { errMsg: "Archivematica resource not found", }, } { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/internal/am/upload_transfer_test.go b/internal/am/upload_transfer_test.go index 5229f5e41..6be71a7a6 100644 --- a/internal/am/upload_transfer_test.go +++ b/internal/am/upload_transfer_test.go @@ -136,7 +136,6 @@ func TestUploadTransferActivity(t *testing.T) { wantNonRetryErr: true, }, } { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/internal/package_/status_test.go b/internal/package_/status_test.go index 1d9888c0f..1af2f90bf 100644 --- a/internal/package_/status_test.go +++ b/internal/package_/status_test.go @@ -45,7 +45,6 @@ func TestStatus(t *testing.T) { }, } for _, tc := range tests { - tc := tc t.Run(fmt.Sprintf("Status_%s", tc.str), func(t *testing.T) { s := NewStatus(tc.str) assert.Assert(t, s != StatusUnknown) diff --git a/internal/persistence/ent/client/client_test.go b/internal/persistence/ent/client/client_test.go index 3f828b163..8437c5fd5 100644 --- a/internal/persistence/ent/client/client_test.go +++ b/internal/persistence/ent/client/client_test.go @@ -183,7 +183,6 @@ func TestCreatePackage(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -370,7 +369,6 @@ func TestUpdatePackage(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/internal/sftp/goclient_test.go b/internal/sftp/goclient_test.go index 8661bdd2d..ac4a1ee3d 100644 --- a/internal/sftp/goclient_test.go +++ b/internal/sftp/goclient_test.go @@ -298,7 +298,6 @@ func TestUpload(t *testing.T) { }, }, } { - tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() @@ -379,7 +378,6 @@ func TestDelete(t *testing.T) { wantErr: "SFTP: unable to remove file \"restricted/test.txt\": permission denied", }, } { - tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/internal/storage/location_test.go b/internal/storage/location_test.go index d56bd9f45..f85e2200d 100644 --- a/internal/storage/location_test.go +++ b/internal/storage/location_test.go @@ -37,8 +37,6 @@ func TestNewInternalLocation(t *testing.T) { }, } for _, tc := range tests { - tc := tc - t.Run(tc.name, func(t *testing.T) { t.Parallel() @@ -108,8 +106,6 @@ func TestNewLocation(t *testing.T) { }, } for _, tc := range tests { - tc := tc - t.Run(tc.name, func(t *testing.T) { t.Parallel() @@ -158,8 +154,6 @@ func TestLocation_Bucket(t *testing.T) { }, } for _, tc := range tests { - tc := tc - t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/internal/storage/types/location_config_test.go b/internal/storage/types/location_config_test.go index a80ce596c..8fefd8715 100644 --- a/internal/storage/types/location_config_test.go +++ b/internal/storage/types/location_config_test.go @@ -94,7 +94,6 @@ func TestLocationConfigEncoding(t *testing.T) { wantErr: "json: error calling MarshalJSON for type types.LocationConfig: unsupported config type: ", }, } { - tt := tt t.Run(name, func(t *testing.T) { t.Parallel() @@ -210,7 +209,6 @@ func TestLocationConfigDecoding(t *testing.T) { wantErr: "multiple config values have been assigned", }, } { - tt := tt t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/storage/types/status_test.go b/internal/storage/types/status_test.go index 82c88eb35..3d0f1945f 100644 --- a/internal/storage/types/status_test.go +++ b/internal/storage/types/status_test.go @@ -38,7 +38,6 @@ func TestPackageStatus(t *testing.T) { status: types.StatusMoving, }, } { - tt := tt t.Run(tt.code, func(t *testing.T) { t.Parallel() diff --git a/internal/watcher/watcher.go b/internal/watcher/watcher.go index 10d4fbd6a..4e986d12b 100644 --- a/internal/watcher/watcher.go +++ b/internal/watcher/watcher.go @@ -95,7 +95,6 @@ func New(ctx context.Context, logger logr.Logger, c *Config) (*serviceImpl, erro minioConfigs := append(c.Minio, c.Embedded) for _, item := range minioConfigs { - item := item w, err := NewMinioWatcher(ctx, logger, item) if err != nil { return nil, err @@ -105,7 +104,6 @@ func New(ctx context.Context, logger logr.Logger, c *Config) (*serviceImpl, erro } for _, item := range c.Filesystem { - item := item w, err := NewFilesystemWatcher(ctx, item) if err != nil { return nil, err @@ -127,7 +125,6 @@ func (svc *serviceImpl) Watchers() []Watcher { ww := []Watcher{} for _, item := range svc.watchers { - item := item ww = append(ww, item) } diff --git a/internal/workflow/activities/bundle_test.go b/internal/workflow/activities/bundle_test.go index 3c023eb98..a747c63d6 100644 --- a/internal/workflow/activities/bundle_test.go +++ b/internal/workflow/activities/bundle_test.go @@ -154,7 +154,6 @@ e91f941be5973ff71f1dccbdd1a32d598881893a7f21be516aca743da38b1689 bagit.txt ), }, } { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/internal/workflow/activities/download_test.go b/internal/workflow/activities/download_test.go index ad1ad3436..4c9f2a781 100644 --- a/internal/workflow/activities/download_test.go +++ b/internal/workflow/activities/download_test.go @@ -60,7 +60,6 @@ func TestDownloadActivity(t *testing.T) { wantErr: fmt.Sprintf("activity error (type: download-activity, scheduledEventID: 0, startedEventID: 0, identity: ): download blob: error loading watcher: unknown watcher %s", watcherName), }, } { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/internal/workflow/activities/zip_test.go b/internal/workflow/activities/zip_test.go index 04fbde795..b39d6afe4 100644 --- a/internal/workflow/activities/zip_test.go +++ b/internal/workflow/activities/zip_test.go @@ -53,7 +53,6 @@ func TestZipActivity(t *testing.T) { wantErr: fmt.Sprintf("ZipActivity: create: open %s: permission denied", restrictedDir.Join(transferName+".zip")), }, } { - tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel()