Skip to content

Commit 99e16d2

Browse files
committed
C#: Include metrics in the database quality diagnostics.
1 parent 8009dde commit 99e16d2

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

csharp/ql/src/Telemetry/DatabaseQualityDiagnostics.ql

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,30 @@ import csharp
99
import DatabaseQuality
1010

1111
private newtype TDbQualityDiagnostic =
12-
TTheDbQualityDiagnostic() {
13-
exists(float percentageGood |
14-
CallTargetStatsReport::percentageOfOk(_, percentageGood)
15-
or
16-
ExprTypeStatsReport::percentageOfOk(_, percentageGood)
17-
|
18-
percentageGood < 95
19-
)
12+
TTheDbQualityDiagnostic(string callMsg, float callTargetOk, string exprMsg, float exprTypeOk) {
13+
CallTargetStatsReport::percentageOfOk(callMsg, callTargetOk) and
14+
ExprTypeStatsReport::percentageOfOk(exprMsg, exprTypeOk) and
15+
[callTargetOk, exprTypeOk] < 95
2016
}
2117

2218
class DbQualityDiagnostic extends TDbQualityDiagnostic {
19+
private string callMsg;
20+
private float callTargetOk;
21+
private float exprTypeOk;
22+
private string exprMsg;
23+
24+
DbQualityDiagnostic() { this = TTheDbQualityDiagnostic(callMsg, callTargetOk, exprMsg, exprTypeOk) }
25+
26+
private string getDbHealth() {
27+
result = callMsg + ": " + callTargetOk.floor() + ". " + exprMsg + ": " + exprTypeOk.floor() + ". "
28+
}
2329
string toString() {
2430
result =
2531
"Scanning C# code completed successfully, but the scan encountered issues. " +
26-
"This may be caused by problems identifying dependencies or use of generated source code, among other reasons -- "
27-
+
28-
"see other CodeQL diagnostics reported on the CodeQL status page for more details of possible causes. "
29-
+
30-
"Addressing these warnings is advisable to avoid false-positive or missing results. If they cannot be addressed, consider scanning C# "
31-
+
32+
"This may be caused by problems identifying dependencies or use of generated source code. " +
33+
"Some metrics of the database quality are: " + this.getDbHealth() +
34+
"Both of these metrics should ideally be above 95%. " +
35+
"Addressing these issues are advisable to avoid false-positives or missing results. If they cannot be addressed, consider scanning C# "+
3236
"using either the `autobuild` or `manual` [build modes](https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages#comparison-of-the-build-modes)."
3337
}
3438
}

0 commit comments

Comments
 (0)