5
5
private import rust
6
6
private import codeql.rust.elements.internal.generated.ParentChild
7
7
8
+ private predicate multipleToStrings ( Element e ) { strictcount ( e .toString ( ) ) > 1 }
9
+
8
10
/**
9
11
* Holds if `e` has more than one `toString()` result.
10
12
*/
11
13
query predicate multipleToStrings ( Element e , string s ) {
12
- s = strictconcat ( e . toString ( ) , ", " ) and
13
- strictcount ( e .toString ( ) ) > 1
14
+ multipleToStrings ( e ) and
15
+ s = strictconcat ( e .toString ( ) , ", " )
14
16
}
15
17
16
18
/**
17
19
* Holds if `e` has more than one `Location`.
18
20
*/
19
21
query predicate multipleLocations ( Locatable e ) { strictcount ( e .getLocation ( ) ) > 1 }
20
22
23
+ private predicate multiplePrimaryQlClasses ( Element e ) { strictcount ( e .getAPrimaryQlClass ( ) ) > 1 }
24
+
21
25
/**
22
26
* Holds if `e` has more than one `getPrimaryQlClasses()` result.
23
27
*/
24
28
query predicate multiplePrimaryQlClasses ( Element e , string s ) {
25
- s = strictconcat ( e . getPrimaryQlClasses ( ) , ", " ) and
26
- strictcount ( e .getAPrimaryQlClass ( ) ) > 1
29
+ multiplePrimaryQlClasses ( e ) and
30
+ s = strictconcat ( e .getPrimaryQlClasses ( ) , ", " )
27
31
}
28
32
29
33
private Element getParent ( Element child ) { child = getChildAndAccessor ( result , _, _) }
30
34
35
+ private predicate multipleParents ( Element child ) { strictcount ( getParent ( child ) ) > 1 }
36
+
31
37
/**
32
38
* Holds if `child` has more than one AST parent.
33
39
*/
34
40
query predicate multipleParents ( Element child , Element parent ) {
35
- parent = getParent ( child ) and
36
- strictcount ( getParent ( child ) ) > 1
41
+ multipleParents ( child ) and
42
+ parent = getParent ( child )
37
43
}
38
44
39
45
/**
@@ -42,14 +48,14 @@ query predicate multipleParents(Element child, Element parent) {
42
48
int getAstInconsistencyCounts ( string type ) {
43
49
// total results from all the AST consistency query predicates.
44
50
type = "Multiple toStrings" and
45
- result = count ( Element e | multipleToStrings ( e , _ ) | e )
51
+ result = count ( Element e | multipleToStrings ( e ) | e )
46
52
or
47
53
type = "Multiple locations" and
48
54
result = count ( Element e | multipleLocations ( e ) | e )
49
55
or
50
56
type = "Multiple primary QL classes" and
51
- result = count ( Element e | multiplePrimaryQlClasses ( e , _ ) | e )
57
+ result = count ( Element e | multiplePrimaryQlClasses ( e ) | e )
52
58
or
53
59
type = "Multiple parents" and
54
- result = count ( Element e | multipleParents ( e , _ ) | e )
60
+ result = count ( Element e | multipleParents ( e ) | e )
55
61
}
0 commit comments