Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion cpp/ql/src/Telemetry/DatabaseQuality.qll
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import cpp
import codeql.util.ReportStats

/** A file that is included in the quality statistics. */
private class RelevantFile extends File {
RelevantFile() { this.fromSource() and exists(this.getRelativePath()) }
}

module CallTargetStats implements StatsSig {
private class RelevantCall extends Call {
RelevantCall() { this.getFile() = any(File f | f.fromSource() and exists(f.getRelativePath())) }
RelevantCall() { this.getFile() instanceof RelevantFile }
}

// We assume that calls with an implicit target are calls that could not be
Expand All @@ -22,4 +27,24 @@ module CallTargetStats implements StatsSig {
string getNotOkText() { result = "calls with missing call target" }
}

private class SourceExpr extends Expr {
SourceExpr() { this.getFile() instanceof RelevantFile }
}

predicate find(SourceExpr e) { not hasGoodType(e) }

private predicate hasGoodType(Expr e) { not e.getType() instanceof ErroneousType }

module ExprTypeStats implements StatsSig {
int getNumberOfOk() { result = count(SourceExpr e | hasGoodType(e)) }

int getNumberOfNotOk() { result = count(SourceExpr e | not hasGoodType(e)) }

string getOkText() { result = "expressions with known type" }

string getNotOkText() { result = "expressions with unknown type" }
}

module CallTargetStatsReport = ReportStats<CallTargetStats>;

module ExprTypeStatsReport = ReportStats<ExprTypeStats>;
5 changes: 4 additions & 1 deletion cpp/ql/src/Telemetry/ExtractorInformation.ql
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ where
(
CallTargetStatsReport::numberOfOk(key, value) or
CallTargetStatsReport::numberOfNotOk(key, value) or
CallTargetStatsReport::percentageOfOk(key, value)
CallTargetStatsReport::percentageOfOk(key, value) or
ExprTypeStatsReport::numberOfOk(key, value) or
ExprTypeStatsReport::numberOfNotOk(key, value) or
ExprTypeStatsReport::percentageOfOk(key, value)
) and
/* Infinity */
value != 1.0 / 0.0 and
Expand Down
Loading