|  | 
|  | 1 | +import ql | 
|  | 2 | + | 
|  | 3 | +// NOT OK -- Predicate starts with "get" but does not return a value | 
|  | 4 | +predicate getValue() { none() } | 
|  | 5 | + | 
|  | 6 | +// OK -- starts with get and returns a value | 
|  | 7 | +string getData() { result = "data" } | 
|  | 8 | + | 
|  | 9 | +// OK -- starts with get but followed by a lowercase letter, probably should be ignored | 
|  | 10 | +predicate getterFunction() { none() } | 
|  | 11 | + | 
|  | 12 | +// OK -- starts with get and returns a value | 
|  | 13 | +string getImplementation() { result = "implementation" } | 
|  | 14 | + | 
|  | 15 | +// OK -- is an alias | 
|  | 16 | +predicate getAlias = getImplementation/0; | 
|  | 17 | + | 
|  | 18 | +// OK -- Starts with "get" but followed by a lowercase letter, probably be ignored | 
|  | 19 | +predicate getvalue() { none() } | 
|  | 20 | + | 
|  | 21 | +// OK -- Does not start with "get", should be ignored | 
|  | 22 | +predicate retrieveValue() { none() } | 
|  | 23 | + | 
|  | 24 | +// NOT OK -- starts with get and does not return value | 
|  | 25 | +predicate getImplementation2() { none() } | 
|  | 26 | + | 
|  | 27 | +// NOT OK -- is an alias for a predicate which does not have a return value | 
|  | 28 | +predicate getAlias2 = getImplementation2/0; | 
|  | 29 | + | 
|  | 30 | +// NOT OK -- starts with as and does not return value | 
|  | 31 | +predicate asValue() { none() } | 
|  | 32 | + | 
|  | 33 | +// OK -- starts with as but followed by a lowercase letter, probably should be ignored | 
|  | 34 | +predicate assessment() { none() } | 
|  | 35 | + | 
|  | 36 | +// OK -- starts with as and returns a value | 
|  | 37 | +string asString() { result = "string" } | 
|  | 38 | + | 
|  | 39 | +// OK -- starts with get and returns a value | 
|  | 40 | +HiddenType getInjectableCompositeActionNode() { | 
|  | 41 | +  exists(HiddenType hidden | result = hidden.toString()) | 
|  | 42 | +} | 
|  | 43 | + | 
|  | 44 | +// OK | 
|  | 45 | +predicate implementation4() { none() } | 
|  | 46 | + | 
|  | 47 | +// NOT OK -- is an alias | 
|  | 48 | +predicate getAlias4 = implementation4/0; | 
|  | 49 | + | 
|  | 50 | +// OK -- is an alias | 
|  | 51 | +predicate alias5 = implementation4/0; | 
|  | 52 | + | 
|  | 53 | +int root() { none() } | 
|  | 54 | + | 
|  | 55 | +predicate edge(int x, int y) { none() } | 
|  | 56 | + | 
|  | 57 | +// OK -- Higher-order predicate | 
|  | 58 | +int getDistance(int x) = shortestDistances(root/0, edge/2)(_, x, result) | 
|  | 59 | + | 
|  | 60 | +// NOT OK -- Higher-order predicate that does not return a value even though has 'get' in the name | 
|  | 61 | +predicate getDistance2(int x, int y) = shortestDistances(root/0, edge/2)(_, x, y) | 
|  | 62 | + | 
|  | 63 | +// OK | 
|  | 64 | +predicate unresolvedAlias = unresolved/0; | 
|  | 65 | + | 
|  | 66 | +// OK -- unresolved alias | 
|  | 67 | +predicate getUnresolvedAlias = unresolved/0; | 
0 commit comments