Skip to content
Closed
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
21 changes: 21 additions & 0 deletions rust/ql/src/queries/telemetry/DatabaseQuality.qll
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import codeql.util.ReportStats
import codeql.rust.elements.internal.CallExprImpl::Impl as CallExprImpl
import codeql.rust.internal.typeinference.TypeInference as TypeInference
import codeql.rust.internal.typeinference.Type
import codeql.rust.internal.typeinference.TypeMention

/**
* A file that is included in the quality statistics.
Expand Down Expand Up @@ -89,8 +90,28 @@ module ExprTypeStats implements StatsSig {
string getNotOkText() { result = "expressions with unknown type" }
}

module TypeMentionStats implements StatsSig {
additional class Candidate extends TypeMention {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hvitved how would you prefer this metric be constructed? My only real interest in this is making the DCA report clean of errors and thus easier to read.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was gonna point out exactly this issue. I wasn't aware adding the report to all languages would result en errors for languages that do not supply the data, so perhaps we should just move the report so it only applies to Unified.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I think we should close this PR and make an internal DCA fix instead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't aware adding the report to all languages would result en errors for languages that do not supply the data

It's not exactly explicit errors, but you get a table with 53 or so rows with no data that are marked as "interesting". We can either restrict the new table to unified, or change the conclusion so that empty data is not "interesting" (thus the table won't be displayed in the summary-of-summaries).

So I think we should close this PR and make an internal DCA fix instead.

OK, if you're doing that could you link to it here please (or I can probably fit it in tomorrow).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have merged an internal fix.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I see it. Closing this.

predicate isOk() { this.getType() = any(Type t | not t instanceof UnknownType) }
}

int getNumberOfOk() {
result = count(Candidate c | c.getFile() instanceof RelevantFile and c.isOk())
}

int getNumberOfNotOk() {
result = count(Candidate c | c.getFile() instanceof RelevantFile and not c.isOk())
}

string getOkText() { result = "resolvable type mentions" }

string getNotOkText() { result = "unresolvable type mentions" }
}

module CallTargetStatsReport = ReportStats<CallTargetStats>;

module MacroCallTargetStatsReport = ReportStats<MacroCallTargetStats>;

module ExprTypeStatsReport = ReportStats<ExprTypeStats>;

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