@@ -8,8 +8,21 @@ import rust
88import codeql.util.ReportStats
99import codeql.rust.internal.TypeInference as TypeInference
1010
11+ /**
12+ * A file that is included in the quality statistics.
13+ */
14+ private class RelevantFile extends File {
15+ RelevantFile ( ) {
16+ // files that are not skipped by the compilation
17+ not this .( ExtractedFile ) .isSkippedByCompilation ( )
18+ }
19+ }
20+
1121module CallTargetStats implements StatsSig {
12- int getNumberOfOk ( ) { result = count ( CallExprBase c | exists ( c .getStaticTarget ( ) ) ) }
22+ int getNumberOfOk ( ) {
23+ result =
24+ count ( CallExprBase c | c .getFile ( ) instanceof RelevantFile and exists ( c .getStaticTarget ( ) ) )
25+ }
1326
1427 private predicate isLambdaCall ( CallExpr call ) {
1528 exists ( Expr receiver | receiver = call .getFunction ( ) |
@@ -19,6 +32,7 @@ module CallTargetStats implements StatsSig {
1932 }
2033
2134 additional predicate isNotOkCall ( CallExprBase c ) {
35+ c .getFile ( ) instanceof RelevantFile and
2236 not exists ( c .getStaticTarget ( ) ) and
2337 not isLambdaCall ( c )
2438 }
@@ -31,9 +45,13 @@ module CallTargetStats implements StatsSig {
3145}
3246
3347module MacroCallTargetStats implements StatsSig {
34- int getNumberOfOk ( ) { result = count ( MacroCall c | c .hasMacroCallExpansion ( ) ) }
48+ int getNumberOfOk ( ) {
49+ result = count ( MacroCall c | c .getFile ( ) instanceof RelevantFile and c .hasMacroCallExpansion ( ) )
50+ }
3551
36- additional predicate isNotOkCall ( MacroCall c ) { not c .hasMacroCallExpansion ( ) }
52+ additional predicate isNotOkCall ( MacroCall c ) {
53+ c .getFile ( ) instanceof RelevantFile and not c .hasMacroCallExpansion ( )
54+ }
3755
3856 int getNumberOfNotOk ( ) { result = count ( MacroCall c | isNotOkCall ( c ) ) }
3957
@@ -45,9 +63,23 @@ module MacroCallTargetStats implements StatsSig {
4563private predicate hasGoodType ( Expr e ) { exists ( TypeInference:: inferType ( e , _) ) }
4664
4765module ExprTypeStats implements StatsSig {
48- int getNumberOfOk ( ) { result = count ( Expr e | e .fromSource ( ) and hasGoodType ( e ) ) }
66+ int getNumberOfOk ( ) {
67+ result =
68+ count ( Expr e |
69+ e .getFile ( ) instanceof RelevantFile and
70+ e .fromSource ( ) and
71+ hasGoodType ( e )
72+ )
73+ }
4974
50- int getNumberOfNotOk ( ) { result = count ( Expr e | e .fromSource ( ) and not hasGoodType ( e ) ) }
75+ int getNumberOfNotOk ( ) {
76+ result =
77+ count ( Expr e |
78+ e .getFile ( ) instanceof RelevantFile and
79+ e .fromSource ( ) and
80+ not hasGoodType ( e )
81+ )
82+ }
5183
5284 string getOkText ( ) { result = "expressions with known type" }
5385
0 commit comments