Skip to content

Commit b0ef0f0

Browse files
committed
Java: Include metrics in the database quality diagnostics and lower threshold.
1 parent ed11a32 commit b0ef0f0

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

java/ql/src/Telemetry/DatabaseQualityDiagnostics.ql

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,39 @@
88
import java
99
import DatabaseQuality
1010

11+
private predicate diagnostic(string msg, float value, float threshold) {
12+
CallTargetStatsReport::percentageOfOk(msg, value) and
13+
threshold = 85
14+
or
15+
ExprTypeStatsReport::percentageOfOk(msg, value) and
16+
threshold = 85
17+
}
18+
1119
private newtype TDbQualityDiagnostic =
1220
TTheDbQualityDiagnostic() {
13-
exists(float percentageGood |
14-
CallTargetStatsReport::percentageOfOk(_, percentageGood)
15-
or
16-
ExprTypeStatsReport::percentageOfOk(_, percentageGood)
17-
|
18-
percentageGood < 95
21+
exists(float percentageGood, float threshold |
22+
diagnostic(_, percentageGood, threshold) and
23+
percentageGood < threshold
1924
)
2025
}
2126

27+
private string getDbHealth() {
28+
result =
29+
strictconcat(string msg, float value, float threshold |
30+
diagnostic(msg, value, threshold)
31+
|
32+
msg + ": " + value.floor() + " % (threshold " + threshold.floor() + " %)", ". "
33+
)
34+
}
35+
2236
class DbQualityDiagnostic extends TDbQualityDiagnostic {
2337
string toString() {
2438
result =
2539
"Scanning Java 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 Java "
40+
"This may be caused by problems identifying dependencies or use of generated source code. " +
41+
"Some metrics of the database quality are: " + getDbHealth() + ". " +
42+
"Ideally these metrics should be above their thresholds. " +
43+
"Addressing these issues is advisable to avoid false-positives or missing results. If they cannot be addressed, consider scanning Java "
3144
+
3245
"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)."
3346
}

0 commit comments

Comments
 (0)