mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
QL: move ql/non-us-spelling implementation to Query.qll file
This commit is contained in:
24
ql/ql/src/codeql_ql/style/docs/NonUSSpellingQuery.qll
Normal file
24
ql/ql/src/codeql_ql/style/docs/NonUSSpellingQuery.qll
Normal file
@@ -0,0 +1,24 @@
|
||||
predicate non_us_word(string wrong, string right) {
|
||||
exists(string s |
|
||||
wrong = s.splitAt("/", 0) and
|
||||
right = s.splitAt("/", 1) and
|
||||
s =
|
||||
[
|
||||
"colour/color", "authorise/authorize", "analyse/analyze", "behaviour/behavior",
|
||||
"modelling/modeling"
|
||||
]
|
||||
)
|
||||
}
|
||||
|
||||
bindingset[s]
|
||||
predicate contains_non_us_spelling(string s, string wrong, string right) {
|
||||
non_us_word(wrong, right) and
|
||||
(
|
||||
s.matches("%" + wrong + "%") and
|
||||
wrong != "analyse"
|
||||
or
|
||||
// analyses (as a noun) is fine
|
||||
s.regexpMatch(".*analyse[^s].*") and
|
||||
wrong = "analyse"
|
||||
)
|
||||
}
|
||||
@@ -9,31 +9,7 @@
|
||||
*/
|
||||
|
||||
import ql
|
||||
|
||||
predicate non_us_word(string wrong, string right) {
|
||||
exists(string s |
|
||||
wrong = s.splitAt("/", 0) and
|
||||
right = s.splitAt("/", 1) and
|
||||
s =
|
||||
[
|
||||
"colour/color", "authorise/authorize", "analyse/analyze", "behaviour/behavior",
|
||||
"modelling/modeling"
|
||||
]
|
||||
)
|
||||
}
|
||||
|
||||
bindingset[s]
|
||||
predicate contains_non_us_spelling(string s, string wrong, string right) {
|
||||
non_us_word(wrong, right) and
|
||||
(
|
||||
s.matches("%" + wrong + "%") and
|
||||
wrong != "analyse"
|
||||
or
|
||||
// analyses (as a noun) is fine
|
||||
s.regexpMatch(".*analyse[^s].*") and
|
||||
wrong = "analyse"
|
||||
)
|
||||
}
|
||||
import codeql_ql.style.docs.NonUSSpellingQuery
|
||||
|
||||
from QLDoc doc, string wrong, string right
|
||||
where contains_non_us_spelling(doc.getContents().toLowerCase(), wrong, right)
|
||||
|
||||
Reference in New Issue
Block a user