From 02bb96a3a5e78ce0e5b00a8dfdd02908d558ecc0 Mon Sep 17 00:00:00 2001 From: Selena Goods Date: Tue, 25 Feb 2025 15:46:02 -0500 Subject: [PATCH] Replace `tenv` and `exportloopref` linters with `usetesting` and `copyloopvar` --- .golangci.yml | 6 +++--- datasource/timeouts/schema_test.go | 8 ++++---- datasource/timeouts/timeouts.go | 1 + datasource/timeouts/timeouts_test.go | 6 +++--- ephemeral/timeouts/schema_test.go | 8 ++++---- ephemeral/timeouts/timeouts.go | 1 + ephemeral/timeouts/timeouts_test.go | 6 +++--- internal/validators/timeduration_test.go | 2 +- resource/timeouts/schema_test.go | 4 ++-- resource/timeouts/timeouts.go | 1 + resource/timeouts/timeouts_test.go | 12 ++++++------ 11 files changed, 29 insertions(+), 26 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 0396bb9..bdef0fc 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,13 +1,13 @@ issues: - max-per-linter: 0 + max-issues-per-linter: 0 max-same-issues: 0 linters: disable-all: true enable: + - copyloopvar - durationcheck - errcheck - - exportloopref - forcetypeassert - gofmt - gosimple @@ -19,7 +19,7 @@ linters: - paralleltest - predeclared - staticcheck - - tenv - unconvert - unparam - unused + - usetesting \ No newline at end of file diff --git a/datasource/timeouts/schema_test.go b/datasource/timeouts/schema_test.go index ba79949..88a7fe9 100644 --- a/datasource/timeouts/schema_test.go +++ b/datasource/timeouts/schema_test.go @@ -74,7 +74,7 @@ func TestBlockWithOpts(t *testing.T) { } for name, test := range tests { - name, test := name, test + t.Run(name, func(t *testing.T) { t.Parallel() actual := timeouts.BlockWithOpts(context.Background(), test.opts) @@ -118,7 +118,7 @@ func TestBlock(t *testing.T) { } for name, test := range tests { - name, test := name, test + t.Run(name, func(t *testing.T) { t.Parallel() actual := timeouts.Block(context.Background()) @@ -189,7 +189,7 @@ func TestAttributesWithOpts(t *testing.T) { } for name, test := range tests { - name, test := name, test + t.Run(name, func(t *testing.T) { t.Parallel() actual := timeouts.AttributesWithOpts(context.Background(), test.opts) @@ -234,7 +234,7 @@ func TestAttributes(t *testing.T) { } for name, test := range tests { - name, test := name, test + t.Run(name, func(t *testing.T) { t.Parallel() actual := timeouts.Attributes(context.Background()) diff --git a/datasource/timeouts/timeouts.go b/datasource/timeouts/timeouts.go index b9049cf..2b11149 100644 --- a/datasource/timeouts/timeouts.go +++ b/datasource/timeouts/timeouts.go @@ -131,6 +131,7 @@ func (t Value) getTimeout(ctx context.Context, timeoutName string, defaultTimeou // No type assertion check is required as the schema guarantees that the object attributes // are types.String. + //nolint:forcetypeassert timeout, err := time.ParseDuration(value.(types.String).ValueString()) if err != nil { diags.Append(diag.NewErrorDiagnostic( diff --git a/datasource/timeouts/timeouts_test.go b/datasource/timeouts/timeouts_test.go index 0c8346e..a794ef6 100644 --- a/datasource/timeouts/timeouts_test.go +++ b/datasource/timeouts/timeouts_test.go @@ -56,7 +56,7 @@ func TestTimeoutsTypeValueFromTerraform(t *testing.T) { } for name, test := range tests { - name, test := name, test + t.Run(name, func(t *testing.T) { t.Parallel() @@ -127,7 +127,7 @@ func TestTimeoutsTypeEqual(t *testing.T) { }, } for name, test := range tests { - name, test := name, test + t.Run(name, func(t *testing.T) { t.Parallel() @@ -216,7 +216,7 @@ func TestTimeoutsValueRead(t *testing.T) { } for name, test := range tests { - name, test := name, test + t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/ephemeral/timeouts/schema_test.go b/ephemeral/timeouts/schema_test.go index 319d4cb..65839c1 100644 --- a/ephemeral/timeouts/schema_test.go +++ b/ephemeral/timeouts/schema_test.go @@ -74,7 +74,7 @@ func TestBlockWithOpts(t *testing.T) { } for name, test := range tests { - name, test := name, test + t.Run(name, func(t *testing.T) { t.Parallel() actual := timeouts.BlockWithOpts(context.Background(), test.opts) @@ -118,7 +118,7 @@ func TestBlock(t *testing.T) { } for name, test := range tests { - name, test := name, test + t.Run(name, func(t *testing.T) { t.Parallel() actual := timeouts.Block(context.Background()) @@ -189,7 +189,7 @@ func TestAttributesWithOpts(t *testing.T) { } for name, test := range tests { - name, test := name, test + t.Run(name, func(t *testing.T) { t.Parallel() actual := timeouts.AttributesWithOpts(context.Background(), test.opts) @@ -234,7 +234,7 @@ func TestAttributes(t *testing.T) { } for name, test := range tests { - name, test := name, test + t.Run(name, func(t *testing.T) { t.Parallel() actual := timeouts.Attributes(context.Background()) diff --git a/ephemeral/timeouts/timeouts.go b/ephemeral/timeouts/timeouts.go index f09e70e..de08cc7 100644 --- a/ephemeral/timeouts/timeouts.go +++ b/ephemeral/timeouts/timeouts.go @@ -131,6 +131,7 @@ func (t Value) getTimeout(ctx context.Context, timeoutName string, defaultTimeou // No type assertion check is required as the schema guarantees that the object attributes // are types.String. + //nolint:forcetypeassert timeout, err := time.ParseDuration(value.(types.String).ValueString()) if err != nil { diags.Append(diag.NewErrorDiagnostic( diff --git a/ephemeral/timeouts/timeouts_test.go b/ephemeral/timeouts/timeouts_test.go index 3590699..c9a75c5 100644 --- a/ephemeral/timeouts/timeouts_test.go +++ b/ephemeral/timeouts/timeouts_test.go @@ -56,7 +56,7 @@ func TestTimeoutsTypeValueFromTerraform(t *testing.T) { } for name, test := range tests { - name, test := name, test + t.Run(name, func(t *testing.T) { t.Parallel() @@ -127,7 +127,7 @@ func TestTimeoutsTypeEqual(t *testing.T) { }, } for name, test := range tests { - name, test := name, test + t.Run(name, func(t *testing.T) { t.Parallel() @@ -216,7 +216,7 @@ func TestTimeoutsValueOpen(t *testing.T) { } for name, test := range tests { - name, test := name, test + t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/internal/validators/timeduration_test.go b/internal/validators/timeduration_test.go index 53fbb0f..fb8ffca 100644 --- a/internal/validators/timeduration_test.go +++ b/internal/validators/timeduration_test.go @@ -47,7 +47,7 @@ func TestTimeDuration(t *testing.T) { } for name, test := range tests { - name, test := name, test + t.Run(name, func(t *testing.T) { t.Parallel() request := validator.StringRequest{ diff --git a/resource/timeouts/schema_test.go b/resource/timeouts/schema_test.go index 9918b08..c1d3920 100644 --- a/resource/timeouts/schema_test.go +++ b/resource/timeouts/schema_test.go @@ -158,7 +158,7 @@ func TestBlock(t *testing.T) { } for name, test := range tests { - name, test := name, test + t.Run(name, func(t *testing.T) { t.Parallel() actual := timeouts.Block(context.Background(), test.opts) @@ -379,7 +379,7 @@ func TestAttributes(t *testing.T) { } for name, test := range tests { - name, test := name, test + t.Run(name, func(t *testing.T) { t.Parallel() actual := timeouts.Attributes(context.Background(), test.opts) diff --git a/resource/timeouts/timeouts.go b/resource/timeouts/timeouts.go index bd1be82..ab0b72a 100644 --- a/resource/timeouts/timeouts.go +++ b/resource/timeouts/timeouts.go @@ -149,6 +149,7 @@ func (t Value) getTimeout(ctx context.Context, timeoutName string, defaultTimeou // No type assertion check is required as the schema guarantees that the object attributes // are types.String. + //nolint:forcetypeassert timeout, err := time.ParseDuration(value.(types.String).ValueString()) if err != nil { diags.Append(diag.NewErrorDiagnostic( diff --git a/resource/timeouts/timeouts_test.go b/resource/timeouts/timeouts_test.go index 130edd7..7d9b4c7 100644 --- a/resource/timeouts/timeouts_test.go +++ b/resource/timeouts/timeouts_test.go @@ -71,7 +71,7 @@ func TestTimeoutsTypeValueFromTerraform(t *testing.T) { } for name, test := range tests { - name, test := name, test + t.Run(name, func(t *testing.T) { t.Parallel() @@ -142,7 +142,7 @@ func TestTimeoutsTypeEqual(t *testing.T) { }, } for name, test := range tests { - name, test := name, test + t.Run(name, func(t *testing.T) { t.Parallel() @@ -231,7 +231,7 @@ func TestTimeoutsValueCreate(t *testing.T) { } for name, test := range tests { - name, test := name, test + t.Run(name, func(t *testing.T) { t.Parallel() @@ -325,7 +325,7 @@ func TestTimeoutsValueRead(t *testing.T) { } for name, test := range tests { - name, test := name, test + t.Run(name, func(t *testing.T) { t.Parallel() @@ -419,7 +419,7 @@ func TestTimeoutsValueUpdate(t *testing.T) { } for name, test := range tests { - name, test := name, test + t.Run(name, func(t *testing.T) { t.Parallel() @@ -513,7 +513,7 @@ func TestTimeoutsValueDelete(t *testing.T) { } for name, test := range tests { - name, test := name, test + t.Run(name, func(t *testing.T) { t.Parallel()