Skip to content

Commit f8ce11b

Browse files
committed
Rust: Improve File.getNumberOfLinesOfCode().
1 parent 7da2845 commit f8ce11b

File tree

5 files changed

+9
-6
lines changed

5 files changed

+9
-6
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
private import codeql.Locations
44
private import codeql.util.FileSystem
5+
private import codeql.rust.elements.Module
56
private import codeql.rust.elements.SourceFile
67
private import codeql.rust.elements.AstNode
78

@@ -44,7 +45,9 @@ class File extends Container, Impl::File {
4445
result =
4546
count(int line |
4647
exists(AstNode node, Location loc |
47-
not node instanceof SourceFile and loc = node.getLocation()
48+
not node instanceof Module and
49+
not node instanceof SourceFile and
50+
loc = node.getLocation()
4851
|
4952
node.getFile() = this and
5053
line = [loc.getStartLine(), loc.getEndLine()] and
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
| 49 |
1+
| 48 |
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
| 49 |
1+
| 48 |
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
| my_struct.rs:0:0:0:0 | my_struct.rs | 21 |
2-
| main.rs:0:0:0:0 | main.rs | 8 |
32
| my_macro.rs:0:0:0:0 | my_macro.rs | 8 |
3+
| main.rs:0:0:0:0 | main.rs | 7 |
44
| lib.rs:0:0:0:0 | lib.rs | 6 |
55
| does_not_compile.rs:0:0:0:0 | does_not_compile.rs | 3 |
66
| error.rs:0:0:0:0 | error.rs | 3 |
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
| Elements extracted | 211 |
22
| Elements unextracted | 0 |
33
| Files extracted | 6 |
4-
| Lines of code extracted | 49 |
5-
| Lines of user code extracted | 49 |
4+
| Lines of code extracted | 48 |
5+
| Lines of user code extracted | 48 |

0 commit comments

Comments
 (0)