File tree Expand file tree Collapse file tree 3 files changed +30
-4
lines changed
test/queries/style/OmittableExists Expand file tree Collapse file tree 3 files changed +30
-4
lines changed Original file line number Diff line number Diff line change 10
10
11
11
import ql
12
12
13
+ class AggregateOrForQuantifier extends AstNode {
14
+ AggregateOrForQuantifier ( ) {
15
+ this instanceof FullAggregate or this instanceof Forex or this instanceof Forall
16
+ }
17
+ }
18
+
13
19
from VarDecl existsArgument , VarAccess use
14
20
where
15
21
existsArgument = any ( Exists e ) .getAnArgument ( ) and
16
22
use = unique( | | existsArgument .getAnAccess ( ) ) and
17
- exists ( Call c , int argPos | c .getArgument ( argPos ) = use |
18
- existsArgument .getType ( ) = c .getTarget ( ) .getParameterType ( argPos ) .getASuperType * ( )
19
- )
23
+ exists ( Call c , int argPos , Type paramType |
24
+ c .getArgument ( argPos ) = use and paramType = c .getTarget ( ) .getParameterType ( argPos )
25
+ |
26
+ existsArgument .getType ( ) = paramType .getASuperType * ( ) and
27
+ not paramType instanceof DatabaseType
28
+ ) and
29
+ not use .getParent * ( ) instanceof AggregateOrForQuantifier
20
30
select existsArgument , "This exists variable can be omitted by using a don't-care expression $@." ,
21
31
use , "in this argument"
Original file line number Diff line number Diff line change 1
- | Test.qll:10 :10:10 :14 | i | This exists variable can be omitted by using a don't-care expression $@. | Test.qll:10 :29:10 :29 | i | in this argument |
1
+ | Test.qll:18 :10:18 :14 | i | This exists variable can be omitted by using a don't-care expression $@. | Test.qll:18 :29:18 :29 | i | in this argument |
Original file line number Diff line number Diff line change @@ -2,10 +2,18 @@ predicate aPredicate(int i) { none() }
2
2
3
3
predicate anotherPredicate ( int i ) { none ( ) }
4
4
5
+ predicate yetAnotherPredicate ( int i , int y ) { none ( ) }
6
+
7
+ predicate dbTypePredicate ( @location l ) { none ( ) }
8
+
5
9
class SmallInt extends int {
6
10
SmallInt ( ) { this = [ 0 .. 10 ] }
7
11
}
8
12
13
+ class Location extends @location {
14
+ string toString ( ) { result = "" }
15
+ }
16
+
9
17
predicate test ( ) {
10
18
exists ( int i | aPredicate ( i ) ) // BAD
11
19
or
@@ -15,5 +23,13 @@ predicate test() {
15
23
or
16
24
exists ( int i | aPredicate ( i ) and exists ( int i2 | i = i2 ) ) // GOOD
17
25
or
26
+ exists ( int i | count ( int y | yetAnotherPredicate ( i , y ) ) > 0 ) // GOOD
27
+ or
28
+ exists ( int i | forex ( int y | yetAnotherPredicate ( i , y ) ) ) // GOOD
29
+ or
30
+ exists ( int i | forall ( int y | yetAnotherPredicate ( i , y ) ) ) // GOOD
31
+ or
18
32
exists ( SmallInt i | aPredicate ( i ) ) // GOOD
33
+ or
34
+ exists ( Location l | dbTypePredicate ( l ) ) // GOOD
19
35
}
You can’t perform that action at this time.
0 commit comments