From 62d0cf7e0d92434219a83a8adb99ede67dcbba9d Mon Sep 17 00:00:00 2001 From: Arthur Baars Date: Wed, 28 May 2025 19:55:13 +0200 Subject: [PATCH 1/2] Rust: restrict line and file counts to include only extracted source files --- rust/ql/src/queries/summary/NumberOfFilesExtractedWithErrors.ql | 2 +- rust/ql/src/queries/summary/Stats.qll | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/ql/src/queries/summary/NumberOfFilesExtractedWithErrors.ql b/rust/ql/src/queries/summary/NumberOfFilesExtractedWithErrors.ql index 23db30f53e96..6f5feb3ea54b 100644 --- a/rust/ql/src/queries/summary/NumberOfFilesExtractedWithErrors.ql +++ b/rust/ql/src/queries/summary/NumberOfFilesExtractedWithErrors.ql @@ -10,7 +10,7 @@ import codeql.files.FileSystem -select count(File f | +select count(ExtractedFile f | exists(f.getRelativePath()) and not f instanceof SuccessfullyExtractedFile ) diff --git a/rust/ql/src/queries/summary/Stats.qll b/rust/ql/src/queries/summary/Stats.qll index db0a05629df9..88411aa2db3b 100644 --- a/rust/ql/src/queries/summary/Stats.qll +++ b/rust/ql/src/queries/summary/Stats.qll @@ -35,7 +35,7 @@ int getLinesOfCode() { result = sum(File f | f.fromSource() | f.getNumberOfLines * Gets a count of the total number of lines of code from the source code directory in the database. */ int getLinesOfUserCode() { - result = sum(File f | exists(f.getRelativePath()) | f.getNumberOfLinesOfCode()) + result = sum(File f | f.fromSource() and exists(f.getRelativePath()) | f.getNumberOfLinesOfCode()) } /** From 5c21c01ad0da37b304ed2114d55b61ba886990ca Mon Sep 17 00:00:00 2001 From: Arthur Baars Date: Mon, 2 Jun 2025 15:42:43 +0200 Subject: [PATCH 2/2] Update rust/ql/src/queries/summary/Stats.qll --- rust/ql/src/queries/summary/Stats.qll | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/ql/src/queries/summary/Stats.qll b/rust/ql/src/queries/summary/Stats.qll index 88411aa2db3b..1feaf3ab48b2 100644 --- a/rust/ql/src/queries/summary/Stats.qll +++ b/rust/ql/src/queries/summary/Stats.qll @@ -35,7 +35,7 @@ int getLinesOfCode() { result = sum(File f | f.fromSource() | f.getNumberOfLines * Gets a count of the total number of lines of code from the source code directory in the database. */ int getLinesOfUserCode() { - result = sum(File f | f.fromSource() and exists(f.getRelativePath()) | f.getNumberOfLinesOfCode()) + result = sum(ExtractedFile f | exists(f.getRelativePath()) | f.getNumberOfLinesOfCode()) } /**