Skip to content

Commit 66c6a4d

Browse files
committed
QL: move ql/non-us-spelling implementation to Query.qll file
1 parent d17879e commit 66c6a4d

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
predicate non_us_word(string wrong, string right) {
2+
exists(string s |
3+
wrong = s.splitAt("/", 0) and
4+
right = s.splitAt("/", 1) and
5+
s =
6+
[
7+
"colour/color", "authorise/authorize", "analyse/analyze", "behaviour/behavior",
8+
"modelling/modeling"
9+
]
10+
)
11+
}
12+
13+
bindingset[s]
14+
predicate contains_non_us_spelling(string s, string wrong, string right) {
15+
non_us_word(wrong, right) and
16+
(
17+
s.matches("%" + wrong + "%") and
18+
wrong != "analyse"
19+
or
20+
// analyses (as a noun) is fine
21+
s.regexpMatch(".*analyse[^s].*") and
22+
wrong = "analyse"
23+
)
24+
}

ql/ql/src/queries/style/docs/NonUSSpelling.ql

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,7 @@
99
*/
1010

1111
import ql
12-
13-
predicate non_us_word(string wrong, string right) {
14-
exists(string s |
15-
wrong = s.splitAt("/", 0) and
16-
right = s.splitAt("/", 1) and
17-
s =
18-
[
19-
"colour/color", "authorise/authorize", "analyse/analyze", "behaviour/behavior",
20-
"modelling/modeling"
21-
]
22-
)
23-
}
24-
25-
bindingset[s]
26-
predicate contains_non_us_spelling(string s, string wrong, string right) {
27-
non_us_word(wrong, right) and
28-
(
29-
s.matches("%" + wrong + "%") and
30-
wrong != "analyse"
31-
or
32-
// analyses (as a noun) is fine
33-
s.regexpMatch(".*analyse[^s].*") and
34-
wrong = "analyse"
35-
)
36-
}
12+
import codeql_ql.style.docs.NonUSSpellingQuery
3713

3814
from QLDoc doc, string wrong, string right
3915
where contains_non_us_spelling(doc.getContents().toLowerCase(), wrong, right)

0 commit comments

Comments
 (0)