|
| 1 | +/** |
| 2 | + * @name Rust extraction information |
| 3 | + * @description Information about the extraction for a Rust database |
| 4 | + * @kind metric |
| 5 | + * @tags summary telemetry |
| 6 | + * @id rust/telemetry/extraction-information |
| 7 | + */ |
| 8 | + |
| 9 | +import rust |
| 10 | +import DatabaseQuality |
| 11 | +import codeql.rust.Diagnostics |
| 12 | + |
| 13 | +predicate fileCount(string key, int value) { |
| 14 | + key = "Number of files" and |
| 15 | + value = strictcount(File f) |
| 16 | +} |
| 17 | + |
| 18 | +predicate fileCountByExtension(string key, int value) { |
| 19 | + exists(string extension | |
| 20 | + key = "Number of files with extension " + extension and |
| 21 | + value = strictcount(File f | f.getExtension() = extension) |
| 22 | + ) |
| 23 | +} |
| 24 | + |
| 25 | +predicate numberOfLinesOfCode(string key, int value) { |
| 26 | + key = "Number of lines of code" and |
| 27 | + value = strictsum(File f | any() | f.getNumberOfLinesOfCode()) |
| 28 | +} |
| 29 | + |
| 30 | +predicate numberOfLinesOfCodeByExtension(string key, int value) { |
| 31 | + exists(string extension | |
| 32 | + key = "Number of lines of code with extension " + extension and |
| 33 | + value = strictsum(File f | f.getExtension() = extension | f.getNumberOfLinesOfCode()) |
| 34 | + ) |
| 35 | +} |
| 36 | + |
| 37 | +predicate extractorDiagnostics(string key, int value) { |
| 38 | + exists(int severity | |
| 39 | + key = "Number of diagnostics with severity " + severity.toString() and |
| 40 | + value = strictcount(Diagnostic d | d.getSeverity() = severity) |
| 41 | + ) |
| 42 | +} |
| 43 | + |
| 44 | +from string key, float value |
| 45 | +where |
| 46 | + ( |
| 47 | + fileCount(key, value) or |
| 48 | + fileCountByExtension(key, value) or |
| 49 | + numberOfLinesOfCode(key, value) or |
| 50 | + numberOfLinesOfCodeByExtension(key, value) or |
| 51 | + extractorDiagnostics(key, value) or |
| 52 | + CallTargetStatsReport::numberOfOk(key, value) or |
| 53 | + CallTargetStatsReport::numberOfNotOk(key, value) or |
| 54 | + CallTargetStatsReport::percentageOfOk(key, value) or |
| 55 | + MacroCallTargetStatsReport::numberOfOk(key, value) or |
| 56 | + MacroCallTargetStatsReport::numberOfNotOk(key, value) or |
| 57 | + MacroCallTargetStatsReport::percentageOfOk(key, value) |
| 58 | + ) and |
| 59 | + /* Infinity */ |
| 60 | + value != 1.0 / 0.0 and |
| 61 | + /* -Infinity */ |
| 62 | + value != -1.0 / 0.0 and |
| 63 | + /* NaN */ |
| 64 | + value != 0.0 / 0.0 |
| 65 | +select key, value |
0 commit comments