Skip to content

Commit 0d5c25b

Browse files
committed
Rust: Repair getNumberOfLinesOfCode.
1 parent d21cbe5 commit 0d5c25b

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

rust/ql/lib/codeql/files/FileSystem.qll

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,13 @@ class Folder = Impl::Folder;
3333
class File extends Container, Impl::File {
3434
/** Holds if this file was extracted from ordinary source code. */
3535
predicate fromSource() { any() }
36+
37+
/**
38+
* Gets the number of lines containing code in this file. This value
39+
* is approximate.
40+
*/
41+
int getNumberOfLinesOfCode() {
42+
result =
43+
count(int line | exists(Location loc | loc.getFile() = this and loc.getStartLine() = line and not loc instanceof EmptyLocation))
44+
}
3645
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55
import rust
66

7-
int getLinesOfCode() {
8-
result = sum(File f | | f.getNumberOfLinesOfCode())
9-
}
7+
int getLinesOfCode() { result = sum(File f | | f.getNumberOfLinesOfCode()) }
108

119
int getLinesOfUserCode() {
1210
result = sum(File f | exists(f.getRelativePath()) | f.getNumberOfLinesOfCode())

0 commit comments

Comments
 (0)