Now the error message reflects properly the prefix

This commit is contained in:
Napalys
2024-11-29 15:54:58 +01:00
parent 96c1086dfc
commit a462ec91f5
2 changed files with 14 additions and 2 deletions

View File

@@ -28,9 +28,21 @@ predicate hasReturnType(Predicate pred) { exists(pred.getReturnType()) }
*/
predicate isAlias(Predicate pred) { exists(pred.(ClasslessPredicate).getAlias()) }
/**
* Returns "get" if the predicate name starts with "get", otherwise "as".
*/
string getPrefix(Predicate pred) {
if pred.getName().matches("get%")
then result = "get"
else
if pred.getName().matches("as%")
then result = "as"
else result = ""
}
from Predicate pred
where
isGetPredicate(pred) and
not hasReturnType(pred) and
not isAlias(pred)
select pred, "This predicate starts with 'get' but does not return a value."
select pred, "This predicate starts with '" + getPrefix(pred) + "' but does not return a value."

View File

@@ -1,3 +1,3 @@
| test.qll:4:11:4:18 | ClasslessPredicate getValue | This predicate starts with 'get' but does not return a value. |
| test.qll:25:11:25:28 | ClasslessPredicate getImplementation2 | This predicate starts with 'get' but does not return a value. |
| test.qll:31:11:31:17 | ClasslessPredicate asValue | This predicate starts with 'get' but does not return a value. |
| test.qll:31:11:31:17 | ClasslessPredicate asValue | This predicate starts with 'as' but does not return a value. |