Skip to content

Commit a462ec9

Browse files
committed
Now the error message reflects properly the prefix
1 parent 96c1086 commit a462ec9

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

ql/ql/src/queries/style/ValidatePredicateGetReturns.ql

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,21 @@ predicate hasReturnType(Predicate pred) { exists(pred.getReturnType()) }
2828
*/
2929
predicate isAlias(Predicate pred) { exists(pred.(ClasslessPredicate).getAlias()) }
3030

31+
/**
32+
* Returns "get" if the predicate name starts with "get", otherwise "as".
33+
*/
34+
string getPrefix(Predicate pred) {
35+
if pred.getName().matches("get%")
36+
then result = "get"
37+
else
38+
if pred.getName().matches("as%")
39+
then result = "as"
40+
else result = ""
41+
}
42+
3143
from Predicate pred
3244
where
3345
isGetPredicate(pred) and
3446
not hasReturnType(pred) and
3547
not isAlias(pred)
36-
select pred, "This predicate starts with 'get' but does not return a value."
48+
select pred, "This predicate starts with '" + getPrefix(pred) + "' but does not return a value."
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
| test.qll:4:11:4:18 | ClasslessPredicate getValue | This predicate starts with 'get' but does not return a value. |
22
| test.qll:25:11:25:28 | ClasslessPredicate getImplementation2 | This predicate starts with 'get' but does not return a value. |
3-
| test.qll:31:11:31:17 | ClasslessPredicate asValue | This predicate starts with 'get' but does not return a value. |
3+
| test.qll:31:11:31:17 | ClasslessPredicate asValue | This predicate starts with 'as' but does not return a value. |

0 commit comments

Comments
 (0)