Skip to content

Commit d9787ef

Browse files
committed
Rust: Include metrics in the database quality diagnostics.
1 parent 572da26 commit d9787ef

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

rust/ql/src/queries/telemetry/DatabaseQualityDiagnostics.ql

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,36 @@ import rust
99
import DatabaseQuality
1010
import codeql.util.Unit
1111

12+
private predicate diagnostic(string msg, float value, float threshold) {
13+
CallTargetStatsReport::percentageOfOk(msg, value) and threshold = 50
14+
or
15+
MacroCallTargetStatsReport::percentageOfOk(msg, value) and threshold = 50
16+
}
17+
18+
private string getDbHealth() {
19+
result =
20+
strictconcat(string msg, float value, float threshold |
21+
diagnostic(msg, value, threshold)
22+
|
23+
msg + ": " + value.floor() + " % (threshold " + threshold.floor() + " %)", ". "
24+
)
25+
}
26+
1227
class DbQualityDiagnostic extends Unit {
1328
DbQualityDiagnostic() {
14-
exists(float percentageGood |
15-
CallTargetStatsReport::percentageOfOk(_, percentageGood) and percentageGood < 50
16-
or
17-
MacroCallTargetStatsReport::percentageOfOk(_, percentageGood) and percentageGood < 50
29+
exists(float percentageGood, float threshold |
30+
diagnostic(_, percentageGood, threshold) and
31+
percentageGood < threshold
1832
)
1933
}
2034

2135
string toString() {
2236
result =
2337
"Scanning Rust code completed successfully, but the scan encountered issues. " +
24-
"This may be caused by problems identifying dependencies or use of generated source code, among other reasons -- "
25-
+
26-
"see other CodeQL diagnostics reported on the CodeQL status page for more details of possible causes. "
27-
+ "Addressing these warnings is advisable to avoid false-positive or missing results."
38+
"This may be caused by problems identifying dependencies or use of generated source code. " +
39+
"Some metrics of the database quality are: " + getDbHealth() + ". " +
40+
"Ideally these metrics should be above their thresholds. " +
41+
"Addressing these issues is advisable to avoid false-positives or missing results."
2842
}
2943
}
3044

0 commit comments

Comments
 (0)