|
8 | 8 | import java |
9 | 9 | import DatabaseQuality |
10 | 10 |
|
| 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 | + |
11 | 19 | private newtype TDbQualityDiagnostic = |
12 | 20 | 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 |
19 | 24 | ) |
20 | 25 | } |
21 | 26 |
|
| 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 | + |
22 | 36 | class DbQualityDiagnostic extends TDbQualityDiagnostic { |
23 | 37 | string toString() { |
24 | 38 | result = |
25 | 39 | "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 " |
31 | 44 | + |
32 | 45 | "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)." |
33 | 46 | } |
|
0 commit comments