Skip to content

Commit c124820

Browse files
committed
Rust: Add summary stats query showing all of the summary data, for convenience.
1 parent 6e9f2a3 commit c124820

File tree

4 files changed

+34
-2
lines changed

4 files changed

+34
-2
lines changed

rust/ql/src/queries/summary/LinesOfCode.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
*/
1010

1111
import rust
12+
import Stats
1213

13-
select sum(File f | | f.getNumberOfLinesOfCode())
14+
select getLinesOfCode()

rust/ql/src/queries/summary/LinesOfUserCode.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
*/
1010

1111
import rust
12+
import Stats
1213

13-
select sum(File f | exists(f.getRelativePath()) | f.getNumberOfLinesOfCode())
14+
select getLinesOfUserCode()

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* Predicates used in summary queries.
3+
*/
4+
5+
import rust
6+
7+
int getLinesOfCode() {
8+
result = sum(File f | | f.getNumberOfLinesOfCode())
9+
}
10+
11+
int getLinesOfUserCode() {
12+
result = sum(File f | exists(f.getRelativePath()) | f.getNumberOfLinesOfCode())
13+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* @name Summary Statistics
3+
* @description A table of summary statistics about a database.
4+
* @kind table
5+
* @id rust/summary/summary-statistics
6+
* @tags summary
7+
*/
8+
9+
import rust
10+
import Stats
11+
12+
from string key, string value
13+
where
14+
key = "Lines of code" and value = getLinesOfCode().toString()
15+
or
16+
key = "Lines of user code" and value = getLinesOfUserCode().toString()
17+
select key, value

0 commit comments

Comments
 (0)