mirror of
https://github.com/github/codeql.git
synced 2026-04-25 08:45:14 +02:00
Rust: Add lines-of-code queries.
This commit is contained in:
13
rust/ql/src/queries/summary/LinesOfCode.ql
Normal file
13
rust/ql/src/queries/summary/LinesOfCode.ql
Normal 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())
|
||||
13
rust/ql/src/queries/summary/LinesOfUserCode.ql
Normal file
13
rust/ql/src/queries/summary/LinesOfUserCode.ql
Normal 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())
|
||||
15
rust/ql/src/queries/summary/LinesOfUserCodeInFiles.ql
Normal file
15
rust/ql/src/queries/summary/LinesOfUserCodeInFiles.ql
Normal 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
|
||||
Reference in New Issue
Block a user