Skip to content

Commit 6827933

Browse files
authored
Replace tenv and exportloopref linters with usetesting and copyloopvar (#173)
1 parent f37813c commit 6827933

File tree

11 files changed

+29
-26
lines changed

11 files changed

+29
-26
lines changed

.golangci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
issues:
2-
max-per-linter: 0
2+
max-issues-per-linter: 0
33
max-same-issues: 0
44

55
linters:
66
disable-all: true
77
enable:
8+
- copyloopvar
89
- durationcheck
910
- errcheck
10-
- exportloopref
1111
- forcetypeassert
1212
- gofmt
1313
- gosimple
@@ -19,7 +19,7 @@ linters:
1919
- paralleltest
2020
- predeclared
2121
- staticcheck
22-
- tenv
2322
- unconvert
2423
- unparam
2524
- unused
25+
- usetesting

datasource/timeouts/schema_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func TestBlockWithOpts(t *testing.T) {
7474
}
7575

7676
for name, test := range tests {
77-
name, test := name, test
77+
7878
t.Run(name, func(t *testing.T) {
7979
t.Parallel()
8080
actual := timeouts.BlockWithOpts(context.Background(), test.opts)
@@ -118,7 +118,7 @@ func TestBlock(t *testing.T) {
118118
}
119119

120120
for name, test := range tests {
121-
name, test := name, test
121+
122122
t.Run(name, func(t *testing.T) {
123123
t.Parallel()
124124
actual := timeouts.Block(context.Background())
@@ -189,7 +189,7 @@ func TestAttributesWithOpts(t *testing.T) {
189189
}
190190

191191
for name, test := range tests {
192-
name, test := name, test
192+
193193
t.Run(name, func(t *testing.T) {
194194
t.Parallel()
195195
actual := timeouts.AttributesWithOpts(context.Background(), test.opts)
@@ -234,7 +234,7 @@ func TestAttributes(t *testing.T) {
234234
}
235235

236236
for name, test := range tests {
237-
name, test := name, test
237+
238238
t.Run(name, func(t *testing.T) {
239239
t.Parallel()
240240
actual := timeouts.Attributes(context.Background())

datasource/timeouts/timeouts.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ func (t Value) getTimeout(ctx context.Context, timeoutName string, defaultTimeou
131131

132132
// No type assertion check is required as the schema guarantees that the object attributes
133133
// are types.String.
134+
//nolint:forcetypeassert
134135
timeout, err := time.ParseDuration(value.(types.String).ValueString())
135136
if err != nil {
136137
diags.Append(diag.NewErrorDiagnostic(

datasource/timeouts/timeouts_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func TestTimeoutsTypeValueFromTerraform(t *testing.T) {
5656
}
5757

5858
for name, test := range tests {
59-
name, test := name, test
59+
6060
t.Run(name, func(t *testing.T) {
6161
t.Parallel()
6262

@@ -127,7 +127,7 @@ func TestTimeoutsTypeEqual(t *testing.T) {
127127
},
128128
}
129129
for name, test := range tests {
130-
name, test := name, test
130+
131131
t.Run(name, func(t *testing.T) {
132132
t.Parallel()
133133

@@ -216,7 +216,7 @@ func TestTimeoutsValueRead(t *testing.T) {
216216
}
217217

218218
for name, test := range tests {
219-
name, test := name, test
219+
220220
t.Run(name, func(t *testing.T) {
221221
t.Parallel()
222222

ephemeral/timeouts/schema_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func TestBlockWithOpts(t *testing.T) {
7474
}
7575

7676
for name, test := range tests {
77-
name, test := name, test
77+
7878
t.Run(name, func(t *testing.T) {
7979
t.Parallel()
8080
actual := timeouts.BlockWithOpts(context.Background(), test.opts)
@@ -118,7 +118,7 @@ func TestBlock(t *testing.T) {
118118
}
119119

120120
for name, test := range tests {
121-
name, test := name, test
121+
122122
t.Run(name, func(t *testing.T) {
123123
t.Parallel()
124124
actual := timeouts.Block(context.Background())
@@ -189,7 +189,7 @@ func TestAttributesWithOpts(t *testing.T) {
189189
}
190190

191191
for name, test := range tests {
192-
name, test := name, test
192+
193193
t.Run(name, func(t *testing.T) {
194194
t.Parallel()
195195
actual := timeouts.AttributesWithOpts(context.Background(), test.opts)
@@ -234,7 +234,7 @@ func TestAttributes(t *testing.T) {
234234
}
235235

236236
for name, test := range tests {
237-
name, test := name, test
237+
238238
t.Run(name, func(t *testing.T) {
239239
t.Parallel()
240240
actual := timeouts.Attributes(context.Background())

ephemeral/timeouts/timeouts.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ func (t Value) getTimeout(ctx context.Context, timeoutName string, defaultTimeou
131131

132132
// No type assertion check is required as the schema guarantees that the object attributes
133133
// are types.String.
134+
//nolint:forcetypeassert
134135
timeout, err := time.ParseDuration(value.(types.String).ValueString())
135136
if err != nil {
136137
diags.Append(diag.NewErrorDiagnostic(

ephemeral/timeouts/timeouts_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func TestTimeoutsTypeValueFromTerraform(t *testing.T) {
5656
}
5757

5858
for name, test := range tests {
59-
name, test := name, test
59+
6060
t.Run(name, func(t *testing.T) {
6161
t.Parallel()
6262

@@ -127,7 +127,7 @@ func TestTimeoutsTypeEqual(t *testing.T) {
127127
},
128128
}
129129
for name, test := range tests {
130-
name, test := name, test
130+
131131
t.Run(name, func(t *testing.T) {
132132
t.Parallel()
133133

@@ -216,7 +216,7 @@ func TestTimeoutsValueOpen(t *testing.T) {
216216
}
217217

218218
for name, test := range tests {
219-
name, test := name, test
219+
220220
t.Run(name, func(t *testing.T) {
221221
t.Parallel()
222222

internal/validators/timeduration_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func TestTimeDuration(t *testing.T) {
4747
}
4848

4949
for name, test := range tests {
50-
name, test := name, test
50+
5151
t.Run(name, func(t *testing.T) {
5252
t.Parallel()
5353
request := validator.StringRequest{

resource/timeouts/schema_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ func TestBlock(t *testing.T) {
158158
}
159159

160160
for name, test := range tests {
161-
name, test := name, test
161+
162162
t.Run(name, func(t *testing.T) {
163163
t.Parallel()
164164
actual := timeouts.Block(context.Background(), test.opts)
@@ -379,7 +379,7 @@ func TestAttributes(t *testing.T) {
379379
}
380380

381381
for name, test := range tests {
382-
name, test := name, test
382+
383383
t.Run(name, func(t *testing.T) {
384384
t.Parallel()
385385
actual := timeouts.Attributes(context.Background(), test.opts)

resource/timeouts/timeouts.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ func (t Value) getTimeout(ctx context.Context, timeoutName string, defaultTimeou
149149

150150
// No type assertion check is required as the schema guarantees that the object attributes
151151
// are types.String.
152+
//nolint:forcetypeassert
152153
timeout, err := time.ParseDuration(value.(types.String).ValueString())
153154
if err != nil {
154155
diags.Append(diag.NewErrorDiagnostic(

0 commit comments

Comments
 (0)