|
8 | 8 | import csharp |
9 | 9 | import DatabaseQuality |
10 | 10 |
|
11 | | -private int getThreshold() { result = 85 } |
| 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 | +} |
12 | 18 |
|
13 | 19 | private newtype TDbQualityDiagnostic = |
14 | | - TTheDbQualityDiagnostic(string callMsg, float callTargetOk, string exprMsg, float exprTypeOk) { |
15 | | - CallTargetStatsReport::percentageOfOk(callMsg, callTargetOk) and |
16 | | - ExprTypeStatsReport::percentageOfOk(exprMsg, exprTypeOk) and |
17 | | - [callTargetOk, exprTypeOk] < getThreshold() |
18 | | - } |
19 | | - |
20 | | -class DbQualityDiagnostic extends TDbQualityDiagnostic { |
21 | | - private string callMsg; |
22 | | - private float callTargetOk; |
23 | | - private float exprTypeOk; |
24 | | - private string exprMsg; |
25 | | - |
26 | | - DbQualityDiagnostic() { |
27 | | - this = TTheDbQualityDiagnostic(callMsg, callTargetOk, exprMsg, exprTypeOk) |
| 20 | + TTheDbQualityDiagnostic() { |
| 21 | + exists(float percentageGood, float threshold | |
| 22 | + diagnostic(_, percentageGood, threshold) and |
| 23 | + percentageGood < threshold |
| 24 | + ) |
28 | 25 | } |
29 | 26 |
|
30 | | - private string getDbHealth() { |
31 | | - result = |
32 | | - callMsg + ": " + callTargetOk.floor() + ". " + exprMsg + ": " + exprTypeOk.floor() + ". " |
33 | | - } |
| 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 | +} |
34 | 35 |
|
| 36 | +class DbQualityDiagnostic extends TDbQualityDiagnostic { |
35 | 37 | string toString() { |
36 | 38 | result = |
37 | 39 | "Scanning C# code completed successfully, but the scan encountered issues. " + |
38 | 40 | "This may be caused by problems identifying dependencies or use of generated source code. " + |
39 | | - "Some metrics of the database quality are: " + this.getDbHealth() + |
40 | | - "Both of these metrics should ideally be above " + getThreshold() + ". " + |
| 41 | + "Some metrics of the database quality are: " + getDbHealth() + ". " + |
| 42 | + "Ideally these metrics should be above their thresholds. " + |
41 | 43 | "Addressing these issues is advisable to avoid false-positives or missing results. If they cannot be addressed, consider scanning C# " |
42 | 44 | + |
43 | 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)." |
|
0 commit comments