Skip to content

Commit e90ab7b

Browse files
aibaarshvitved
authored andcommitted
Rust: fix diagnostics tests
1 parent 457632e commit e90ab7b

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

rust/ql/src/queries/diagnostics/UnresolvedMacroCalls.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
import rust
99

1010
from MacroCall mc
11-
where not mc.hasMacroCallExpansion()
11+
where mc.fromSource() and not mc.hasMacroCallExpansion()
1212
select mc, "Macro call was not resolved to a target."

rust/ql/src/queries/summary/Stats.qll

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ private import codeql.rust.security.WeakSensitiveDataHashingExtensions
2828
/**
2929
* Gets a count of the total number of lines of code in the database.
3030
*/
31-
int getLinesOfCode() { result = sum(File f | | f.getNumberOfLinesOfCode()) }
31+
int getLinesOfCode() { result = sum(File f | f.fromSource() | f.getNumberOfLinesOfCode()) }
3232

3333
/**
3434
* 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) {
109109
* Gets summary statistics about extraction.
110110
*/
111111
predicate extractionStats(string key, int value) {
112-
key = "Extraction errors" and value = count(ExtractionError e)
112+
key = "Extraction errors" and
113+
value = count(ExtractionError e | not exists(e.getLocation()) or e.getLocation().fromSource())
113114
or
114-
key = "Extraction warnings" and value = count(ExtractionWarning w)
115+
key = "Extraction warnings" and
116+
value = count(ExtractionWarning w | not exists(w.getLocation()) or w.getLocation().fromSource())
115117
or
116118
key = "Files extracted - total" and value = count(ExtractedFile f | exists(f.getRelativePath()))
117119
or
@@ -133,11 +135,13 @@ predicate extractionStats(string key, int value) {
133135
or
134136
key = "Lines of user code extracted" and value = getLinesOfUserCode()
135137
or
136-
key = "Macro calls - total" and value = count(MacroCall mc)
138+
key = "Macro calls - total" and value = count(MacroCall mc | mc.fromSource())
137139
or
138-
key = "Macro calls - resolved" and value = count(MacroCall mc | mc.hasMacroCallExpansion())
140+
key = "Macro calls - resolved" and
141+
value = count(MacroCall mc | mc.fromSource() and mc.hasMacroCallExpansion())
139142
or
140-
key = "Macro calls - unresolved" and value = count(MacroCall mc | not mc.hasMacroCallExpansion())
143+
key = "Macro calls - unresolved" and
144+
value = count(MacroCall mc | mc.fromSource() and not mc.hasMacroCallExpansion())
141145
}
142146

143147
/**
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
| 77 |
1+
| 60 |

rust/ql/test/query-tests/diagnostics/SummaryStatsReduced.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
| Inconsistencies - Path resolution | 0 |
1010
| Inconsistencies - SSA | 0 |
1111
| Inconsistencies - data flow | 0 |
12-
| Lines of code extracted | 77 |
12+
| Lines of code extracted | 60 |
1313
| Lines of user code extracted | 60 |
1414
| Macro calls - resolved | 8 |
1515
| Macro calls - total | 9 |

0 commit comments

Comments
 (0)