Skip to content

Commit b87befc

Browse files
committed
add check for double-whitespace in alert-messages
1 parent e53382c commit b87befc

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

ql/ql/src/queries/style/AlertMessage.ql

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,14 @@ String wrongFlowsPhrase(Select sel, string kind) {
164164
)
165165
}
166166

167+
/**
168+
* Gets a string element that contains double whitespace.
169+
*/
170+
String doubleWhitespace(Select sel) {
171+
result = getSelectPart(sel, _) and
172+
result.getValue().regexpMatch(".*\\s\\s.*")
173+
}
174+
167175
from AstNode node, string msg
168176
where
169177
not node.getLocation().getFile().getAbsolutePath().matches("%/test/%") and
@@ -194,5 +202,8 @@ where
194202
or
195203
node = wrongFlowsPhrase(_, "taint") and
196204
msg = "Use \"depends on\" instead of \"flows to\" in taint tracking queries."
205+
or
206+
node = doubleWhitespace(_) and
207+
msg = "Avoid using double whitespace in alert messages."
197208
)
198209
select node, msg

0 commit comments

Comments
 (0)