|
8 | 8 | import csharp
|
9 | 9 | import DatabaseQuality
|
10 | 10 |
|
| 11 | +private int getThreshold() { result = 85 } |
| 12 | + |
11 | 13 | private newtype TDbQualityDiagnostic =
|
12 |
| - TTheDbQualityDiagnostic() { |
13 |
| - exists(float percentageGood | |
14 |
| - CallTargetStatsReport::percentageOfOk(_, percentageGood) |
15 |
| - or |
16 |
| - ExprTypeStatsReport::percentageOfOk(_, percentageGood) |
17 |
| - | |
18 |
| - percentageGood < 95 |
19 |
| - ) |
| 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() |
20 | 18 | }
|
21 | 19 |
|
22 | 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) |
| 28 | + } |
| 29 | + |
| 30 | + private string getDbHealth() { |
| 31 | + result = |
| 32 | + callMsg + ": " + callTargetOk.floor() + ". " + exprMsg + ": " + exprTypeOk.floor() + ". " |
| 33 | + } |
| 34 | + |
23 | 35 | string toString() {
|
24 | 36 | result =
|
25 | 37 | "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# " |
| 38 | + "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 | + "Addressing these issues is advisable to avoid false-positives or missing results. If they cannot be addressed, consider scanning C# " |
31 | 42 | +
|
32 | 43 | "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 | 44 | }
|
|
0 commit comments