File tree Expand file tree Collapse file tree 2 files changed +30
-2
lines changed
Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change 11import cpp
22import codeql.util.ReportStats
33
4+ /** A file that is included in the quality statistics. */
5+ private class RelevantFile extends File {
6+ RelevantFile ( ) { this .fromSource ( ) and exists ( this .getRelativePath ( ) ) }
7+ }
8+
49module CallTargetStats implements StatsSig {
510 private class RelevantCall extends Call {
6- RelevantCall ( ) { this .getFile ( ) = any ( File f | f . fromSource ( ) and exists ( f . getRelativePath ( ) ) ) }
11+ RelevantCall ( ) { this .getFile ( ) instanceof RelevantFile }
712 }
813
914 // We assume that calls with an implicit target are calls that could not be
@@ -22,4 +27,24 @@ module CallTargetStats implements StatsSig {
2227 string getNotOkText ( ) { result = "calls with missing call target" }
2328}
2429
30+ private class SourceExpr extends Expr {
31+ SourceExpr ( ) { this .getFile ( ) instanceof RelevantFile }
32+ }
33+
34+ predicate find ( SourceExpr e ) { not hasGoodType ( e ) }
35+
36+ private predicate hasGoodType ( Expr e ) { not e .getType ( ) instanceof ErroneousType }
37+
38+ module ExprTypeStats implements StatsSig {
39+ int getNumberOfOk ( ) { result = count ( SourceExpr e | hasGoodType ( e ) ) }
40+
41+ int getNumberOfNotOk ( ) { result = count ( SourceExpr e | not hasGoodType ( e ) ) }
42+
43+ string getOkText ( ) { result = "expressions with known type" }
44+
45+ string getNotOkText ( ) { result = "expressions with unknown type" }
46+ }
47+
2548module CallTargetStatsReport = ReportStats< CallTargetStats > ;
49+
50+ module ExprTypeStatsReport = ReportStats< ExprTypeStats > ;
Original file line number Diff line number Diff line change 1414 (
1515 CallTargetStatsReport:: numberOfOk ( key , value ) or
1616 CallTargetStatsReport:: numberOfNotOk ( key , value ) or
17- CallTargetStatsReport:: percentageOfOk ( key , value )
17+ CallTargetStatsReport:: percentageOfOk ( key , value ) or
18+ ExprTypeStatsReport:: numberOfOk ( key , value ) or
19+ ExprTypeStatsReport:: numberOfNotOk ( key , value ) or
20+ ExprTypeStatsReport:: percentageOfOk ( key , value )
1821 ) and
1922 /* Infinity */
2023 value != 1.0 / 0.0 and
You can’t perform that action at this time.
0 commit comments