Skip to content

Commit 76fef28

Browse files
committed
don't repeat the alert-location as a link
1 parent 88439fc commit 76fef28

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,16 @@ String doubleWhitespace(Select sel) {
184184
result.getValue().regexpMatch(".*\\s\\s.*")
185185
}
186186

187+
/**
188+
* Gets an expression that repeats the alert-loc as a link.
189+
*/
190+
VarAccess getAlertLocLink(Select sel) {
191+
result = sel.getExpr(0).(VarAccess).getDeclaration().getAnAccess() and
192+
exists(int msgIndex | sel.getExpr(msgIndex) = sel.getMessage() |
193+
result = sel.getExpr(any(int i | i > msgIndex))
194+
)
195+
}
196+
187197
from AstNode node, string msg, Select sel
188198
where
189199
not node.getLocation().getFile().getAbsolutePath().matches("%/test/%") and
@@ -218,5 +228,8 @@ where
218228
or
219229
node = doubleWhitespace(sel) and
220230
msg = "Avoid using double whitespace in alert messages."
231+
or
232+
node = getAlertLocLink(sel) and
233+
msg = "Don't repeat the alert location as a link."
221234
)
222235
select node, msg

0 commit comments

Comments
 (0)