Rust: fix diagnostics tests

This commit is contained in:
Arthur Baars
2025-05-20 16:51:16 +02:00
committed by Tom Hvitved
parent 457632e10e
commit e90ab7b881
4 changed files with 13 additions and 9 deletions

View File

@@ -8,5 +8,5 @@
import rust
from MacroCall mc
where not mc.hasMacroCallExpansion()
where mc.fromSource() and not mc.hasMacroCallExpansion()
select mc, "Macro call was not resolved to a target."

View File

@@ -28,7 +28,7 @@ private import codeql.rust.security.WeakSensitiveDataHashingExtensions
/**
* Gets a count of the total number of lines of code in the database.
*/
int getLinesOfCode() { result = sum(File f | | f.getNumberOfLinesOfCode()) }
int getLinesOfCode() { result = sum(File f | f.fromSource() | f.getNumberOfLinesOfCode()) }
/**
* Gets a count of the total number of lines of code from the source code directory in the database.
@@ -109,9 +109,11 @@ predicate elementStats(string key, int value) {
* Gets summary statistics about extraction.
*/
predicate extractionStats(string key, int value) {
key = "Extraction errors" and value = count(ExtractionError e)
key = "Extraction errors" and
value = count(ExtractionError e | not exists(e.getLocation()) or e.getLocation().fromSource())
or
key = "Extraction warnings" and value = count(ExtractionWarning w)
key = "Extraction warnings" and
value = count(ExtractionWarning w | not exists(w.getLocation()) or w.getLocation().fromSource())
or
key = "Files extracted - total" and value = count(ExtractedFile f | exists(f.getRelativePath()))
or
@@ -133,11 +135,13 @@ predicate extractionStats(string key, int value) {
or
key = "Lines of user code extracted" and value = getLinesOfUserCode()
or
key = "Macro calls - total" and value = count(MacroCall mc)
key = "Macro calls - total" and value = count(MacroCall mc | mc.fromSource())
or
key = "Macro calls - resolved" and value = count(MacroCall mc | mc.hasMacroCallExpansion())
key = "Macro calls - resolved" and
value = count(MacroCall mc | mc.fromSource() and mc.hasMacroCallExpansion())
or
key = "Macro calls - unresolved" and value = count(MacroCall mc | not mc.hasMacroCallExpansion())
key = "Macro calls - unresolved" and
value = count(MacroCall mc | mc.fromSource() and not mc.hasMacroCallExpansion())
}
/**

View File

@@ -1 +1 @@
| 77 |
| 60 |

View File

@@ -9,7 +9,7 @@
| Inconsistencies - Path resolution | 0 |
| Inconsistencies - SSA | 0 |
| Inconsistencies - data flow | 0 |
| Lines of code extracted | 77 |
| Lines of code extracted | 60 |
| Lines of user code extracted | 60 |
| Macro calls - resolved | 8 |
| Macro calls - total | 9 |