Skip to content

Commit d60a7b7

Browse files
committed
refactor: simplification
1 parent 0e525a4 commit d60a7b7

38 files changed

+782
-133
lines changed

testdata/src/contextbackground/basic/basic_test.go

+19
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,25 @@ import (
99
"testing"
1010
)
1111

12+
func bar() func(t *testing.T) {
13+
return func(t *testing.T) {
14+
context.Background() // want `context\.Background\(\) could be replaced by t\.Context\(\) in .+`
15+
}
16+
}
17+
18+
func bur(t *testing.T) func() {
19+
return func() {
20+
context.Background() // want `context\.Background\(\) could be replaced by t\.Context\(\) in .+`
21+
}
22+
}
23+
24+
func bir(t *testing.T) func() {
25+
context.Background() // want `context\.Background\(\) could be replaced by t\.Context\(\) in .+`
26+
return func() {
27+
context.Background() // want `context\.Background\(\) could be replaced by t\.Context\(\) in .+`
28+
}
29+
}
30+
1231
func Test_NoName(_ *testing.T) {
1332
context.Background() // want `context\.Background\(\) could be replaced by <t/b>\.Context\(\) in .+`
1433
}

testdata/src/contextbackground/basic/basic_test.go.golden

+19
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,25 @@ import (
99
"testing"
1010
)
1111

12+
func bar() func(t *testing.T) {
13+
return func(t *testing.T) {
14+
t.Context() // want `context\.Background\(\) could be replaced by t\.Context\(\) in .+`
15+
}
16+
}
17+
18+
func bur(t *testing.T) func() {
19+
return func() {
20+
t.Context() // want `context\.Background\(\) could be replaced by t\.Context\(\) in .+`
21+
}
22+
}
23+
24+
func bir(t *testing.T) func() {
25+
t.Context() // want `context\.Background\(\) could be replaced by t\.Context\(\) in .+`
26+
return func() {
27+
t.Context() // want `context\.Background\(\) could be replaced by t\.Context\(\) in .+`
28+
}
29+
}
30+
1231
func Test_NoName(_ *testing.T) {
1332
context.Background() // want `context\.Background\(\) could be replaced by <t/b>\.Context\(\) in .+`
1433
}

testdata/src/contextbackground/disable/disable_test.go

+19
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,25 @@ import (
99
"testing"
1010
)
1111

12+
func bar() func(t *testing.T) {
13+
return func(t *testing.T) {
14+
context.Background()
15+
}
16+
}
17+
18+
func bur(t *testing.T) func() {
19+
return func() {
20+
context.Background()
21+
}
22+
}
23+
24+
func bir(t *testing.T) func() {
25+
context.Background()
26+
return func() {
27+
context.Background()
28+
}
29+
}
30+
1231
func Test_NoName(_ *testing.T) {
1332
context.Background()
1433
}

testdata/src/contextbackground/dot/dot_test.go

+19
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,25 @@ import (
99
"testing"
1010
)
1111

12+
func bar() func(t *testing.T) {
13+
return func(t *testing.T) {
14+
Background() // want `context\.Background\(\) could be replaced by t\.Context\(\) in .+`
15+
}
16+
}
17+
18+
func bur(t *testing.T) func() {
19+
return func() {
20+
Background() // want `context\.Background\(\) could be replaced by t\.Context\(\) in .+`
21+
}
22+
}
23+
24+
func bir(t *testing.T) func() {
25+
Background() // want `context\.Background\(\) could be replaced by t\.Context\(\) in .+`
26+
return func() {
27+
Background() // want `context\.Background\(\) could be replaced by t\.Context\(\) in .+`
28+
}
29+
}
30+
1231
func Test_NoName(_ *testing.T) {
1332
Background() // want `context\.Background\(\) could be replaced by <t/b>\.Context\(\) in .+`
1433
}

testdata/src/contextbackground/dot/dot_test.go.golden

+19
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,25 @@ import (
99
"testing"
1010
)
1111

12+
func bar() func(t *testing.T) {
13+
return func(t *testing.T) {
14+
t.Context() // want `context\.Background\(\) could be replaced by t\.Context\(\) in .+`
15+
}
16+
}
17+
18+
func bur(t *testing.T) func() {
19+
return func() {
20+
t.Context() // want `context\.Background\(\) could be replaced by t\.Context\(\) in .+`
21+
}
22+
}
23+
24+
func bir(t *testing.T) func() {
25+
t.Context() // want `context\.Background\(\) could be replaced by t\.Context\(\) in .+`
26+
return func() {
27+
t.Context() // want `context\.Background\(\) could be replaced by t\.Context\(\) in .+`
28+
}
29+
}
30+
1231
func Test_NoName(_ *testing.T) {
1332
Background() // want `context\.Background\(\) could be replaced by <t/b>\.Context\(\) in .+`
1433
}

testdata/src/contextbackground/nottestfiles/nottestfiles.go

+19
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,25 @@ import (
99
"testing"
1010
)
1111

12+
func bar() func(t *testing.T) {
13+
return func(t *testing.T) {
14+
context.Background() // want `context\.Background\(\) could be replaced by t\.Context\(\) in .+`
15+
}
16+
}
17+
18+
func bur(t *testing.T) func() {
19+
return func() {
20+
context.Background() // want `context\.Background\(\) could be replaced by t\.Context\(\) in .+`
21+
}
22+
}
23+
24+
func bir(t *testing.T) func() {
25+
context.Background() // want `context\.Background\(\) could be replaced by t\.Context\(\) in .+`
26+
return func() {
27+
context.Background() // want `context\.Background\(\) could be replaced by t\.Context\(\) in .+`
28+
}
29+
}
30+
1231
func FunctionNoName(_ *testing.T) {
1332
context.Background() // want `context\.Background\(\) could be replaced by <t/b>\.Context\(\) in .+`
1433
}

testdata/src/contextbackground/nottestfiles/nottestfiles.go.golden

+19
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,25 @@ import (
99
"testing"
1010
)
1111

12+
func bar() func(t *testing.T) {
13+
return func(t *testing.T) {
14+
t.Context() // want `context\.Background\(\) could be replaced by t\.Context\(\) in .+`
15+
}
16+
}
17+
18+
func bur(t *testing.T) func() {
19+
return func() {
20+
t.Context() // want `context\.Background\(\) could be replaced by t\.Context\(\) in .+`
21+
}
22+
}
23+
24+
func bir(t *testing.T) func() {
25+
t.Context() // want `context\.Background\(\) could be replaced by t\.Context\(\) in .+`
26+
return func() {
27+
t.Context() // want `context\.Background\(\) could be replaced by t\.Context\(\) in .+`
28+
}
29+
}
30+
1231
func FunctionNoName(_ *testing.T) {
1332
context.Background() // want `context\.Background\(\) could be replaced by <t/b>\.Context\(\) in .+`
1433
}

testdata/src/contexttodo/basic/basic_test.go

+19
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,25 @@ import (
99
"testing"
1010
)
1111

12+
func bar() func(t *testing.T) {
13+
return func(t *testing.T) {
14+
context.TODO() // want `context\.TODO\(\) could be replaced by t\.Context\(\) in .+`
15+
}
16+
}
17+
18+
func bur(t *testing.T) func() {
19+
return func() {
20+
context.TODO() // want `context\.TODO\(\) could be replaced by t\.Context\(\) in .+`
21+
}
22+
}
23+
24+
func bir(t *testing.T) func() {
25+
context.TODO() // want `context\.TODO\(\) could be replaced by t\.Context\(\) in .+`
26+
return func() {
27+
context.TODO() // want `context\.TODO\(\) could be replaced by t\.Context\(\) in .+`
28+
}
29+
}
30+
1231
func Test_NoName(_ *testing.T) {
1332
context.TODO() // want `context\.TODO\(\) could be replaced by <t/b>\.Context\(\) in .+`
1433
}

testdata/src/contexttodo/basic/basic_test.go.golden

+19
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,25 @@ import (
99
"testing"
1010
)
1111

12+
func bar() func(t *testing.T) {
13+
return func(t *testing.T) {
14+
t.Context() // want `context\.TODO\(\) could be replaced by t\.Context\(\) in .+`
15+
}
16+
}
17+
18+
func bur(t *testing.T) func() {
19+
return func() {
20+
t.Context() // want `context\.TODO\(\) could be replaced by t\.Context\(\) in .+`
21+
}
22+
}
23+
24+
func bir(t *testing.T) func() {
25+
t.Context() // want `context\.TODO\(\) could be replaced by t\.Context\(\) in .+`
26+
return func() {
27+
t.Context() // want `context\.TODO\(\) could be replaced by t\.Context\(\) in .+`
28+
}
29+
}
30+
1231
func Test_NoName(_ *testing.T) {
1332
context.TODO() // want `context\.TODO\(\) could be replaced by <t/b>\.Context\(\) in .+`
1433
}

testdata/src/contexttodo/disable/disable_test.go

+19
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,25 @@ import (
99
"testing"
1010
)
1111

12+
func bar() func(t *testing.T) {
13+
return func(t *testing.T) {
14+
context.TODO()
15+
}
16+
}
17+
18+
func bur(t *testing.T) func() {
19+
return func() {
20+
context.TODO()
21+
}
22+
}
23+
24+
func bir(t *testing.T) func() {
25+
context.TODO()
26+
return func() {
27+
context.TODO()
28+
}
29+
}
30+
1231
func Test_NoName(_ *testing.T) {
1332
context.TODO()
1433
}

testdata/src/contexttodo/dot/dot_test.go

+21-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package dot
22

33
import (
4-
"context"
54
. "context"
65
"errors"
76
"fmt"
@@ -10,6 +9,25 @@ import (
109
"testing"
1110
)
1211

12+
func bar() func(t *testing.T) {
13+
return func(t *testing.T) {
14+
TODO() // want `context\.TODO\(\) could be replaced by t\.Context\(\) in .+`
15+
}
16+
}
17+
18+
func bur(t *testing.T) func() {
19+
return func() {
20+
TODO() // want `context\.TODO\(\) could be replaced by t\.Context\(\) in .+`
21+
}
22+
}
23+
24+
func bir(t *testing.T) func() {
25+
TODO() // want `context\.TODO\(\) could be replaced by t\.Context\(\) in .+`
26+
return func() {
27+
TODO() // want `context\.TODO\(\) could be replaced by t\.Context\(\) in .+`
28+
}
29+
}
30+
1331
func Test_NoName(_ *testing.T) {
1432
TODO() // want `context\.TODO\(\) could be replaced by <t/b>\.Context\(\) in .+`
1533
}
@@ -81,7 +99,7 @@ func Test_GoStmt(t *testing.T) {
8199
}
82100

83101
func Test_GoStmt_arg(t *testing.T) {
84-
go func(ctx context.Context) {}(TODO()) // want `context\.TODO\(\) could be replaced by t\.Context\(\) in .+`
102+
go func(ctx Context) {}(TODO()) // want `context\.TODO\(\) could be replaced by t\.Context\(\) in .+`
85103
}
86104

87105
func Test_CallExpr_recursive(t *testing.T) {
@@ -121,7 +139,7 @@ func Test_SwitchStmt_case(t *testing.T) {
121139
}
122140

123141
func Test_DeclStmt(t *testing.T) {
124-
var ctx context.Context = TODO() // want `context\.TODO\(\) could be replaced by t\.Context\(\) in .+`
142+
var ctx Context = TODO() // want `context\.TODO\(\) could be replaced by t\.Context\(\) in .+`
125143
_ = ctx
126144
}
127145

testdata/src/contexttodo/dot/dot_test.go.golden

+21-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package dot
22

33
import (
4-
"context"
54
. "context"
65
"errors"
76
"fmt"
@@ -10,6 +9,25 @@ import (
109
"testing"
1110
)
1211

12+
func bar() func(t *testing.T) {
13+
return func(t *testing.T) {
14+
t.Context() // want `context\.TODO\(\) could be replaced by t\.Context\(\) in .+`
15+
}
16+
}
17+
18+
func bur(t *testing.T) func() {
19+
return func() {
20+
t.Context() // want `context\.TODO\(\) could be replaced by t\.Context\(\) in .+`
21+
}
22+
}
23+
24+
func bir(t *testing.T) func() {
25+
t.Context() // want `context\.TODO\(\) could be replaced by t\.Context\(\) in .+`
26+
return func() {
27+
t.Context() // want `context\.TODO\(\) could be replaced by t\.Context\(\) in .+`
28+
}
29+
}
30+
1331
func Test_NoName(_ *testing.T) {
1432
TODO() // want `context\.TODO\(\) could be replaced by <t/b>\.Context\(\) in .+`
1533
}
@@ -81,7 +99,7 @@ func Test_GoStmt(t *testing.T) {
8199
}
82100

83101
func Test_GoStmt_arg(t *testing.T) {
84-
go func(ctx context.Context) {}(t.Context()) // want `context\.TODO\(\) could be replaced by t\.Context\(\) in .+`
102+
go func(ctx Context) {}(t.Context()) // want `context\.TODO\(\) could be replaced by t\.Context\(\) in .+`
85103
}
86104

87105
func Test_CallExpr_recursive(t *testing.T) {
@@ -121,7 +139,7 @@ func Test_SwitchStmt_case(t *testing.T) {
121139
}
122140

123141
func Test_DeclStmt(t *testing.T) {
124-
var ctx context.Context = t.Context() // want `context\.TODO\(\) could be replaced by t\.Context\(\) in .+`
142+
var ctx Context = t.Context() // want `context\.TODO\(\) could be replaced by t\.Context\(\) in .+`
125143
_ = ctx
126144
}
127145

testdata/src/contexttodo/nottestfiles/nottestfiles.go

+19
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,25 @@ import (
99
"testing"
1010
)
1111

12+
func bar() func(t *testing.T) {
13+
return func(t *testing.T) {
14+
context.TODO() // want `context\.TODO\(\) could be replaced by t\.Context\(\) in .+`
15+
}
16+
}
17+
18+
func bur(t *testing.T) func() {
19+
return func() {
20+
context.TODO() // want `context\.TODO\(\) could be replaced by t\.Context\(\) in .+`
21+
}
22+
}
23+
24+
func bir(t *testing.T) func() {
25+
context.TODO() // want `context\.TODO\(\) could be replaced by t\.Context\(\) in .+`
26+
return func() {
27+
context.TODO() // want `context\.TODO\(\) could be replaced by t\.Context\(\) in .+`
28+
}
29+
}
30+
1231
func FunctionNoName(_ *testing.T) {
1332
context.TODO() // want `context\.TODO\(\) could be replaced by <t/b>\.Context\(\) in .+`
1433
}

0 commit comments

Comments
 (0)