@@ -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 }
@@ -32,19 +46,13 @@ module CallTargetStats implements StatsSig {
3246
3347module MacroCallTargetStats implements StatsSig {
3448 int getNumberOfOk ( ) {
35- result =
36- count ( MacroCall c |
37- not c .getFile ( ) .( ExtractedFile ) .isSkippedByCompilation ( ) and c .hasMacroCallExpansion ( )
38- )
49+ result = count ( MacroCall c | c .getFile ( ) instanceof RelevantFile and c .hasMacroCallExpansion ( ) )
3950 }
4051
4152 additional predicate isNotOkCall ( MacroCall c ) { not c .hasMacroCallExpansion ( ) }
4253
4354 int getNumberOfNotOk ( ) {
44- result =
45- count ( MacroCall c |
46- not c .getFile ( ) .( ExtractedFile ) .isSkippedByCompilation ( ) and isNotOkCall ( c )
47- )
55+ result = count ( MacroCall c | c .getFile ( ) instanceof RelevantFile and isNotOkCall ( c ) )
4856 }
4957
5058 string getOkText ( ) { result = "macro calls with call target" }
@@ -55,9 +63,23 @@ module MacroCallTargetStats implements StatsSig {
5563private predicate hasGoodType ( Expr e ) { exists ( TypeInference:: inferType ( e , _) ) }
5664
5765module ExprTypeStats implements StatsSig {
58- 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+ }
5974
60- 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+ }
6183
6284 string getOkText ( ) { result = "expressions with known type" }
6385
0 commit comments