Skip to content

Commit 770f3c2

Browse files
committed
Java: Improve performance of GeneratedFileMarker.
1 parent 968f588 commit 770f3c2

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

java/ql/lib/semmle/code/java/GeneratedFiles.qll

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,17 @@ library class MarkerCommentGeneratedFile extends GeneratedFile {
5454
private class GeneratedFileMarker extends Top {
5555
GeneratedFileMarker() {
5656
exists(string msg | msg = this.(JavadocElement).getText() or msg = this.(KtComment).getText() |
57-
msg.regexpMatch("(?i).*\\bGenerated By\\b.*\\bDo not edit\\b.*") or
58-
msg.regexpMatch("(?i).*\\bThis (file|class|interface|art[ei]fact) (was|is|(has been)) (?:auto[ -]?)?gener(e?)ated.*") or
59-
msg.regexpMatch("(?i).*\\bAny modifications to this file will be lost\\b.*") or
60-
msg.regexpMatch("(?i).*\\bThis (file|class|interface|art[ei]fact) (was|is) (?:mechanically|automatically) generated\\b.*") or
61-
msg.regexpMatch("(?i).*\\bThe following code was (?:auto[ -]?)?generated (?:by|from)\\b.*") or
62-
msg.regexpMatch("(?i).*\\bAutogenerated by Thrift.*") or
63-
msg.regexpMatch("(?i).*\\bGenerated By.*JavaCC.*") or
64-
msg.regexpMatch("(?i).*\\bGenerated from .* by ANTLR.*")
57+
msg.regexpMatch("(?i).*(" +
58+
concat([
59+
"\\bGenerated By\\b.*\\bDo not edit\\b",
60+
"\\bThis (file|class|interface|art[ei]fact) (was|is|(has been)) (?:auto[ -]?)?gener(e?)ated",
61+
"\\bAny modifications to this file will be lost\\b",
62+
"\\bThis (file|class|interface|art[ei]fact) (was|is) (?:mechanically|automatically) generated\\b",
63+
"\\bThe following code was (?:auto[ -]?)?generated (?:by|from)\\b",
64+
"\\bAutogenerated by Thrift", "\\bGenerated By.*JavaCC",
65+
"\\bGenerated from .* by ANTLR"
66+
], "|"
67+
) + ").*")
6568
)
6669
}
6770
}

0 commit comments

Comments
 (0)