Rust: Add lines-of-code queries.

This commit is contained in:
Geoffrey White
2024-09-11 17:56:47 +01:00
parent c7be2ae08a
commit 2f98c5ba47
3 changed files with 41 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
/**
* @name Total lines of Rust code in the database
* @description The total number of lines of Rust code across all files, including any libraries and auto-generated files that the extractor sees. This is a useful metric of the size of a database. For all files that were seen during the build, this query counts the lines of code, excluding whitespace or comments.
* @kind metric
* @id rust/summary/lines-of-code
* @tags summary
* lines-of-code
* telemetry
*/
import rust
select sum(File f | | f.getNumberOfLinesOfCode())

View File

@@ -0,0 +1,13 @@
/**
* @name Total lines of user written Rust code in the database
* @description The total number of lines of Rust code from the source code directory. This query counts the lines of code, excluding whitespace or comments.
* @kind metric
* @id rust/summary/lines-of-user-code
* @tags summary
* lines-of-code
* debug
*/
import rust
select sum(File f | exists(f.getRelativePath()) | f.getNumberOfLinesOfCode())

View File

@@ -0,0 +1,15 @@
/**
* @name Lines of user code in files
* @description Measures the number of lines of code in each file from the source directory, ignoring lines that contain only comments or whitespace.
* @kind metric
* @id rust/summary/lines-of-user-code-in-files
* @metricType file
*/
import rust
from File f, int n
where
exists(f.getRelativePath()) and
n = f.getNumberOfLinesOfCode()
select f, n order by n desc