Skip to content

Commit 3b2bca6

Browse files
fix: Adjust severities and fix false positives
1 parent 5cddabc commit 3b2bca6

15 files changed

+332
-38
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### Online
66

7-
Use [ast-grep playground][playground].
7+
Use [ast-grep playground (forked version)][playground].
88

99
[playground]: https://ydx-2147483647.github.io/ast-grep.github.io/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6InR5cHN0IiwicXVlcnkiOiIiLCJyZXdyaXRlIjoiIiwic3RyaWN0bmVzcyI6ImFzdCIsInNlbGVjdG9yIjoiIiwiY29uZmlnIjoiaWQ6IGNvbnRleHRcbmxhbmd1YWdlOiB0eXBzdFxuc2V2ZXJpdHk6IHdhcm5pbmdcbnJ1bGU6XG4gIGtpbmQ6IGNvbnRleHRcbiIsInNvdXJjZSI6IiNjb250ZXh0IGNvdW50ZXIoaGVhZGluZykuZGlzcGxheSgpXG4ifQ==
1010

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,66 @@
11
id: eval
22
snapshots:
3-
'#eval':
3+
'#let f = eval':
44
labels:
55
- source: eval
66
style: primary
7+
start: 9
8+
end: 13
9+
- source: let f = eval
10+
style: secondary
711
start: 1
8-
end: 5
12+
end: 13
13+
? |
14+
#let f = eval("x")
15+
: labels:
16+
- source: eval("x")
17+
style: primary
18+
start: 9
19+
end: 18
20+
- source: eval
21+
style: secondary
22+
start: 9
23+
end: 13
24+
'#let f = std.eval':
25+
labels:
26+
- source: std.eval
27+
style: primary
28+
start: 9
29+
end: 17
30+
- source: let f = std.eval
31+
style: secondary
32+
start: 1
33+
end: 17
34+
? |
35+
#let f = std.eval("x")
36+
: labels:
37+
- source: std.eval("x")
38+
style: primary
39+
start: 9
40+
end: 22
41+
- source: std.eval
42+
style: secondary
43+
start: 9
44+
end: 17
45+
? |
46+
#std.eval("1+1")
47+
: labels:
48+
- source: std.eval("1+1")
49+
style: primary
50+
start: 1
51+
end: 16
52+
- source: std.eval
53+
style: secondary
54+
start: 1
55+
end: 9
56+
? |
57+
#{ eval("1+1") }
58+
: labels:
59+
- source: eval("1+1")
60+
style: primary
61+
start: 3
62+
end: 14
63+
- source: eval
64+
style: secondary
65+
start: 3
66+
end: 7
Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,44 @@
11
id: hard-coded-str
22
snapshots:
33
? |
4-
#"str"
4+
#"\t\t\t"
55
: labels:
6-
- source: '#"str"'
6+
- source: '"\t\t\t"'
77
style: primary
8-
start: 0
9-
end: 6
8+
start: 1
9+
end: 9
10+
? |
11+
#"str"
12+
: labels:
1013
- source: '"str"'
11-
style: secondary
14+
style: primary
1215
start: 1
1316
end: 6
1417
? |
15-
#let x = "str"
18+
#"姓\u{3000}名"
1619
: labels:
17-
- source: '#let x = "str"'
20+
- source: '"姓\u{3000}名"'
1821
style: primary
19-
start: 0
20-
end: 14
22+
start: 1
23+
end: 17
24+
? |
25+
#foo("str")
26+
: labels:
2127
- source: '"str"'
22-
style: secondary
28+
style: primary
29+
start: 5
30+
end: 10
31+
? |
32+
#let x = "str"
33+
: labels:
34+
- source: '"str"'
35+
style: primary
2336
start: 9
2437
end: 14
2538
? |
2639
#{ "str" }
2740
: labels:
28-
- source: '#{ "str" }'
29-
style: primary
30-
start: 0
31-
end: 10
3241
- source: '"str"'
33-
style: secondary
42+
style: primary
3443
start: 3
3544
end: 8
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
id: plugin
2+
snapshots:
3+
? |
4+
#let p = plugin("digestify.wasm")
5+
: labels:
6+
- source: plugin("digestify.wasm")
7+
style: primary
8+
start: 9
9+
end: 33
10+
- source: plugin
11+
style: secondary
12+
start: 9
13+
end: 15
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
id: stateful
2+
snapshots:
3+
? |
4+
#context counter(heading).get()
5+
: labels:
6+
- source: counter(heading)
7+
style: primary
8+
start: 9
9+
end: 25
10+
- source: counter
11+
style: secondary
12+
start: 9
13+
end: 16
14+
? |
15+
#let mine = counter("theorem")
16+
: labels:
17+
- source: counter("theorem")
18+
style: primary
19+
start: 12
20+
end: 30
21+
- source: counter
22+
style: secondary
23+
start: 12
24+
end: 19
25+
? |
26+
#let s = state("x", 0)
27+
: labels:
28+
- source: state("x", 0)
29+
style: primary
30+
start: 9
31+
end: 22
32+
- source: state
33+
style: secondary
34+
start: 9
35+
end: 14
36+
? |
37+
#let s = std.state("x", 0)
38+
: labels:
39+
- source: std.state("x", 0)
40+
style: primary
41+
start: 9
42+
end: 26
43+
- source: std.state
44+
style: secondary
45+
start: 9
46+
end: 18
47+
? |
48+
#state("x", 0)
49+
: labels:
50+
- source: state("x", 0)
51+
style: primary
52+
start: 1
53+
end: 14
54+
- source: state
55+
style: secondary
56+
start: 1
57+
end: 6

rules-tests/eval-test.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
id: eval
22

33
invalid:
4-
- "#eval"
4+
- |
5+
#{ eval("1+1") }
6+
- |
7+
#std.eval("1+1")
8+
- "#let f = eval"
9+
- "#let f = std.eval"
10+
- |
11+
#let f = eval("x")
12+
- |
13+
#let f = std.eval("x")
514
615
valid:
716
- "`eval`"
817
- eval
918
- |
1019
#import "@preview/physica:0.9.5": evaluated
1120
#evaluated
21+
- "#let eval = evaluated"
22+
- "#eval"

rules-tests/hard-coded-str-test.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,35 @@ valid:
99
#set text(weight: "bold")
1010
- |
1111
#range(5).map(str).join(", ")
12+
- |
13+
#panic(
14+
"expected a valid size (zìhào), found "
15+
+ repr(size)
16+
+ ". (All valid sizes: "
17+
+ rules.map(r => repr(r.at(0))).join(", ")
18+
+ ".)",
19+
)
20+
- |
21+
#assert(len > 0, message: "at least one item is required")
22+
- |
23+
#assert.eq(
24+
type(size),
25+
int,
26+
message: "expected an integer, found " + repr(size) + ".",
27+
)
28+
- |
29+
#format.replace(regex("[0-9A-F]+"), m => m.text)
30+
- |
31+
#let SPACE = "\u{3000}"
32+
- |
33+
#"\t"
34+
#"\t\t"
35+
- |
36+
#"\""
37+
- |
38+
#args.has("children")
39+
- |
40+
#it.element.at("body")
1241
1342
invalid:
1443
- |
@@ -17,3 +46,9 @@ invalid:
1746
#{ "str" }
1847
- |
1948
#let x = "str"
49+
- |
50+
#foo("str")
51+
- |
52+
#"\t\t\t"
53+
- |
54+
#"姓\u{3000}名"

rules-tests/plugin-test.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
id: plugin
2+
3+
invalid:
4+
- |
5+
#let p = plugin("digestify.wasm")
6+
7+
valid:
8+
- This is a plugin.

rules-tests/stateful-test.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
id: stateful
2+
3+
invalid:
4+
- |
5+
#let s = state("x", 0)
6+
- |
7+
#let s = std.state("x", 0)
8+
- |
9+
#let mine = counter("theorem")
10+
- |
11+
#context counter(heading).get()
12+
13+
valid:
14+
- |
15+
#let compute(expr) = [
16+
#s.update(x => eval(expr.replace("x", str(x))))
17+
New value is #context s.get().
18+
]
19+
#std.eval("1+1")
20+
- |
21+
#context mine.display()
22+
#mine.step()

rules/context.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
id: context
22
language: typst
3-
severity: warning
3+
severity: info
44
rule:
55
kind: context

0 commit comments

Comments
 (0)