Skip to content

Commit de683a4

Browse files
committed
Adopt https://github.com/ast-grep/ast-grep as a faster partial replacement for eg
1 parent f0929b6 commit de683a4

15 files changed

+659
-10
lines changed

eg/fmt_errorf_to_errors_new.template

Lines changed: 0 additions & 9 deletions
This file was deleted.

mise.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version = "1.10.18"
33
backend = "aqua:cargo-bins/cargo-binstall"
44

55
[tools."cargo:ast-grep"]
6-
version = "0.32.2"
6+
version = "0.32.3"
77
backend = "cargo:ast-grep"
88

99
[tools.cosign]

mise.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ lockfile = true
77

88
[tools]
99
cargo-binstall = "latest"
10+
"cargo:ast-grep" = "latest"
1011
cosign = "latest"
1112
go = "latest"
1213
"go:github.com/tailscale/depaware" = "latest"
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
id: '!(a < b) to a >= b'
2+
snapshots:
3+
'! ( a < b )':
4+
fixed: a >= b
5+
labels:
6+
- source: '! ( a < b )'
7+
style: primary
8+
start: 0
9+
end: 19
10+
'!(a < b)':
11+
fixed: a >= b
12+
labels:
13+
- source: '!(a < b)'
14+
style: primary
15+
start: 0
16+
end: 8
17+
'!(a<b)':
18+
fixed: a >= b
19+
labels:
20+
- source: '!(a<b)'
21+
style: primary
22+
start: 0
23+
end: 6
24+
'!(foo < bar)':
25+
fixed: foo >= bar
26+
labels:
27+
- source: '!(foo < bar)'
28+
style: primary
29+
start: 0
30+
end: 12
31+
'!(len(a(b("c", "d"))) < len(a(b("c", "d"))))':
32+
fixed: len(a(b("c", "d"))) >= len(a(b("c", "d")))
33+
labels:
34+
- source: '!(len(a(b("c", "d"))) < len(a(b("c", "d"))))'
35+
style: primary
36+
start: 0
37+
end: 44
38+
'!(len(foo) < len(bar))':
39+
fixed: len(foo) >= len(bar)
40+
labels:
41+
- source: '!(len(foo) < len(bar))'
42+
style: primary
43+
start: 0
44+
end: 22
45+
'!(one() < two())':
46+
fixed: one() >= two()
47+
labels:
48+
- source: '!(one() < two())'
49+
style: primary
50+
start: 0
51+
end: 16
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
id: '!(a <= b) to a > b'
2+
snapshots:
3+
'! ( a <= b )':
4+
fixed: a > b
5+
labels:
6+
- source: '! ( a <= b )'
7+
style: primary
8+
start: 0
9+
end: 20
10+
'!(a <= b)':
11+
fixed: a > b
12+
labels:
13+
- source: '!(a <= b)'
14+
style: primary
15+
start: 0
16+
end: 9
17+
'!(a<=b)':
18+
fixed: a > b
19+
labels:
20+
- source: '!(a<=b)'
21+
style: primary
22+
start: 0
23+
end: 7
24+
'!(foo <= bar)':
25+
fixed: foo > bar
26+
labels:
27+
- source: '!(foo <= bar)'
28+
style: primary
29+
start: 0
30+
end: 13
31+
'!(len(a(b("c", "d"))) <= len(a(b("c", "d"))))':
32+
fixed: len(a(b("c", "d"))) > len(a(b("c", "d")))
33+
labels:
34+
- source: '!(len(a(b("c", "d"))) <= len(a(b("c", "d"))))'
35+
style: primary
36+
start: 0
37+
end: 45
38+
'!(len(foo) <= len(bar))':
39+
fixed: len(foo) > len(bar)
40+
labels:
41+
- source: '!(len(foo) <= len(bar))'
42+
style: primary
43+
start: 0
44+
end: 23
45+
'!(one() <= two())':
46+
fixed: one() > two()
47+
labels:
48+
- source: '!(one() <= two())'
49+
style: primary
50+
start: 0
51+
end: 17
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
id: '!(a > b) to a <= b'
2+
snapshots:
3+
'! ( a > b )':
4+
fixed: a <= b
5+
labels:
6+
- source: '! ( a > b )'
7+
style: primary
8+
start: 0
9+
end: 19
10+
'!(a > b)':
11+
fixed: a <= b
12+
labels:
13+
- source: '!(a > b)'
14+
style: primary
15+
start: 0
16+
end: 8
17+
'!(a>b)':
18+
fixed: a <= b
19+
labels:
20+
- source: '!(a>b)'
21+
style: primary
22+
start: 0
23+
end: 6
24+
'!(foo > bar)':
25+
fixed: foo <= bar
26+
labels:
27+
- source: '!(foo > bar)'
28+
style: primary
29+
start: 0
30+
end: 12
31+
'!(len(a(b("c", "d"))) > len(a(b("c", "d"))))':
32+
fixed: len(a(b("c", "d"))) <= len(a(b("c", "d")))
33+
labels:
34+
- source: '!(len(a(b("c", "d"))) > len(a(b("c", "d"))))'
35+
style: primary
36+
start: 0
37+
end: 44
38+
'!(len(foo) > len(bar))':
39+
fixed: len(foo) <= len(bar)
40+
labels:
41+
- source: '!(len(foo) > len(bar))'
42+
style: primary
43+
start: 0
44+
end: 22
45+
'!(one() > two())':
46+
fixed: one() <= two()
47+
labels:
48+
- source: '!(one() > two())'
49+
style: primary
50+
start: 0
51+
end: 16
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
id: '!(a >= b) to a < b'
2+
snapshots:
3+
'! ( a >= b )':
4+
fixed: a < b
5+
labels:
6+
- source: '! ( a >= b )'
7+
style: primary
8+
start: 0
9+
end: 20
10+
'!(a >= b)':
11+
fixed: a < b
12+
labels:
13+
- source: '!(a >= b)'
14+
style: primary
15+
start: 0
16+
end: 9
17+
'!(a>=b)':
18+
fixed: a < b
19+
labels:
20+
- source: '!(a>=b)'
21+
style: primary
22+
start: 0
23+
end: 7
24+
'!(foo >= bar)':
25+
fixed: foo < bar
26+
labels:
27+
- source: '!(foo >= bar)'
28+
style: primary
29+
start: 0
30+
end: 13
31+
'!(len(a(b("c", "d"))) >= len(a(b("c", "d"))))':
32+
fixed: len(a(b("c", "d"))) < len(a(b("c", "d")))
33+
labels:
34+
- source: '!(len(a(b("c", "d"))) >= len(a(b("c", "d"))))'
35+
style: primary
36+
start: 0
37+
end: 45
38+
'!(len(foo) >= len(bar))':
39+
fixed: len(foo) < len(bar)
40+
labels:
41+
- source: '!(len(foo) >= len(bar))'
42+
style: primary
43+
start: 0
44+
end: 23
45+
'!(one() >= two())':
46+
fixed: one() < two()
47+
labels:
48+
- source: '!(one() >= two())'
49+
style: primary
50+
start: 0
51+
end: 17
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
id: errors.New(fmt.Sprintf(...)) to fmt.Errorf(...)
2+
snapshots:
3+
? |
4+
_ = errors.New(fmt.Sprintf("%s: %d", "foo", 1))
5+
: fixed: |
6+
_ = fmt.Errorf("%s: %d", "foo", 1)
7+
labels:
8+
- source: 'errors.New(fmt.Sprintf("%s: %d", "foo", 1))'
9+
style: primary
10+
start: 4
11+
end: 47
12+
- source: errors.New
13+
style: secondary
14+
start: 4
15+
end: 14
16+
- source: fmt.Sprintf
17+
style: secondary
18+
start: 15
19+
end: 26
20+
- source: '("%s: %d", "foo", 1)'
21+
style: secondary
22+
start: 26
23+
end: 46
24+
- source: 'fmt.Sprintf("%s: %d", "foo", 1)'
25+
style: secondary
26+
start: 15
27+
end: 46
28+
- source: '(fmt.Sprintf("%s: %d", "foo", 1))'
29+
style: secondary
30+
start: 14
31+
end: 47
32+
? |
33+
errors.New( fmt.Sprintf ( "%s: %s","foo", "bar") )
34+
: fixed: |
35+
fmt.Errorf( "%s: %s","foo", "bar")
36+
labels:
37+
- source: 'errors.New( fmt.Sprintf ( "%s: %s","foo", "bar") )'
38+
style: primary
39+
start: 0
40+
end: 53
41+
- source: errors.New
42+
style: secondary
43+
start: 0
44+
end: 10
45+
- source: fmt.Sprintf
46+
style: secondary
47+
start: 12
48+
end: 23
49+
- source: '( "%s: %s","foo", "bar")'
50+
style: secondary
51+
start: 25
52+
end: 51
53+
- source: 'fmt.Sprintf ( "%s: %s","foo", "bar")'
54+
style: secondary
55+
start: 12
56+
end: 51
57+
- source: '( fmt.Sprintf ( "%s: %s","foo", "bar") )'
58+
style: secondary
59+
start: 10
60+
end: 53
61+
? |
62+
errors.New(fmt.Sprintf("%s: %d", "foo", 1))
63+
: fixed: |
64+
fmt.Errorf("%s: %d", "foo", 1)
65+
labels:
66+
- source: 'errors.New(fmt.Sprintf("%s: %d", "foo", 1))'
67+
style: primary
68+
start: 0
69+
end: 43
70+
- source: errors.New
71+
style: secondary
72+
start: 0
73+
end: 10
74+
- source: fmt.Sprintf
75+
style: secondary
76+
start: 11
77+
end: 22
78+
- source: '("%s: %d", "foo", 1)'
79+
style: secondary
80+
start: 22
81+
end: 42
82+
- source: 'fmt.Sprintf("%s: %d", "foo", 1)'
83+
style: secondary
84+
start: 11
85+
end: 42
86+
- source: '(fmt.Sprintf("%s: %d", "foo", 1))'
87+
style: secondary
88+
start: 10
89+
end: 43
90+
? |
91+
errors.New(fmt.Sprintf("%s: %d: %t", "widget", 1, true))
92+
: fixed: |
93+
fmt.Errorf("%s: %d: %t", "widget", 1, true)
94+
labels:
95+
- source: 'errors.New(fmt.Sprintf("%s: %d: %t", "widget", 1, true))'
96+
style: primary
97+
start: 0
98+
end: 56
99+
- source: errors.New
100+
style: secondary
101+
start: 0
102+
end: 10
103+
- source: fmt.Sprintf
104+
style: secondary
105+
start: 11
106+
end: 22
107+
- source: '("%s: %d: %t", "widget", 1, true)'
108+
style: secondary
109+
start: 22
110+
end: 55
111+
- source: 'fmt.Sprintf("%s: %d: %t", "widget", 1, true)'
112+
style: secondary
113+
start: 11
114+
end: 55
115+
- source: '(fmt.Sprintf("%s: %d: %t", "widget", 1, true))'
116+
style: secondary
117+
start: 10
118+
end: 56
119+
? |
120+
errors.New(fmt.Sprintf("%s: %s", "foo", "bar"))
121+
: fixed: |
122+
fmt.Errorf("%s: %s", "foo", "bar")
123+
labels:
124+
- source: 'errors.New(fmt.Sprintf("%s: %s", "foo", "bar"))'
125+
style: primary
126+
start: 0
127+
end: 47
128+
- source: errors.New
129+
style: secondary
130+
start: 0
131+
end: 10
132+
- source: fmt.Sprintf
133+
style: secondary
134+
start: 11
135+
end: 22
136+
- source: '("%s: %s", "foo", "bar")'
137+
style: secondary
138+
start: 22
139+
end: 46
140+
- source: 'fmt.Sprintf("%s: %s", "foo", "bar")'
141+
style: secondary
142+
start: 11
143+
end: 46
144+
- source: '(fmt.Sprintf("%s: %s", "foo", "bar"))'
145+
style: secondary
146+
start: 10
147+
end: 47

0 commit comments

Comments
 (0)