Skip to content

Commit 01abcf8

Browse files
committed
Rust: Use just end locations for now, to avoid all false positive lines caused by attached comments.
1 parent 8c87b66 commit 01abcf8

File tree

5 files changed

+6
-7
lines changed

5 files changed

+6
-7
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,10 @@ class File extends Container, Impl::File {
4747
exists(AstNode node, Location loc |
4848
not node instanceof Comment and
4949
not node instanceof SourceFile and
50-
not node instanceof Item and // ignore Items for now as we're getting their locations wrong when a comment is attached
5150
loc = node.getLocation()
5251
|
5352
node.getFile() = this and
54-
line = [loc.getStartLine(), loc.getEndLine()] and
53+
line = [/*loc.getStartLine(), */loc.getEndLine()] and // ignore start locations for now as we're getting them wrong for things with a comment attached
5554
not loc instanceof EmptyLocation
5655
)
5756
)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
| 68 |
1+
| 61 |
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
| 68 |
1+
| 61 |

rust/ql/test/query-tests/diagnostics/LinesOfUserCodeInFiles.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
| comments.rs:0:0:0:0 | comments.rs | 20 |
21
| my_struct.rs:0:0:0:0 | my_struct.rs | 20 |
2+
| comments.rs:0:0:0:0 | comments.rs | 13 |
33
| main.rs:0:0:0:0 | main.rs | 8 |
44
| lib.rs:0:0:0:0 | lib.rs | 7 |
55
| my_macro.rs:0:0:0:0 | my_macro.rs | 7 |
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
| Elements extracted | 290 |
22
| Elements unextracted | 0 |
33
| Files extracted | 7 |
4-
| Lines of code extracted | 68 |
5-
| Lines of user code extracted | 68 |
4+
| Lines of code extracted | 61 |
5+
| Lines of user code extracted | 61 |

0 commit comments

Comments
 (0)