Skip to content

Commit 3a54c10

Browse files
committed
Rust: For now exclude top-level AST elements from LOC counts. This is not ideal.
1 parent 7482603 commit 3a54c10

File tree

5 files changed

+9
-7
lines changed

5 files changed

+9
-7
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ private import codeql.util.FileSystem
55
private import codeql.rust.elements.SourceFile
66
private import codeql.rust.elements.AstNode
77
private import codeql.rust.elements.Comment
8+
private import codeql.rust.elements.internal.generated.ParentChild
89

910
private module Input implements InputSig {
1011
abstract class ContainerBase extends @container {
@@ -47,6 +48,7 @@ class File extends Container, Impl::File {
4748
exists(AstNode node, Location loc |
4849
not node instanceof Comment and
4950
not node instanceof SourceFile and
51+
not getImmediateParent(node) instanceof SourceFile and // ignore top-level elements for now as we're getting their locations wrong when a comment is attached
5052
loc = node.getLocation()
5153
|
5254
node.getFile() = this and
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
| 49 |
1+
| 46 |
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
| 49 |
1+
| 46 |
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
| my_struct.rs:0:0:0:0 | my_struct.rs | 21 |
2-
| main.rs:0:0:0:0 | main.rs | 8 |
3-
| my_macro.rs:0:0:0:0 | my_macro.rs | 8 |
1+
| my_struct.rs:0:0:0:0 | my_struct.rs | 20 |
2+
| main.rs:0:0:0:0 | main.rs | 7 |
3+
| my_macro.rs:0:0:0:0 | my_macro.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 | 216 |
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 | 46 |
5+
| Lines of user code extracted | 46 |

0 commit comments

Comments
 (0)