Skip to content

Commit 551c4e8

Browse files
committed
Rust: Improve getNumberOfLinesOfCode (in particular, it will now include the closing of blocks { } ).
1 parent 0d5c25b commit 551c4e8

File tree

5 files changed

+16
-10
lines changed

5 files changed

+16
-10
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ class File extends Container, Impl::File {
4040
*/
4141
int getNumberOfLinesOfCode() {
4242
result =
43-
count(int line | exists(Location loc | loc.getFile() = this and loc.getStartLine() = line and not loc instanceof EmptyLocation))
43+
count(int line |
44+
exists(Location loc |
45+
loc.getFile() = this and
46+
line = [loc.getStartLine(), loc.getEndLine()] and
47+
not loc instanceof EmptyLocation
48+
)
49+
)
4450
}
4551
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
| 6806 |
1+
| 13437 |
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
| 16 |
1+
| 24 |
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
| my_struct.rs:0:0:0:0 | my_struct.rs | 8 |
2-
| main.rs:0:0:0:0 | main.rs | 3 |
3-
| does_not_compile.rs:0:0:0:0 | does_not_compile.rs | 2 |
4-
| my_macro.rs:0:0:0:0 | my_macro.rs | 2 |
5-
| error.rs:0:0:0:0 | error.rs | 1 |
1+
| my_struct.rs:0:0:0:0 | my_struct.rs | 11 |
2+
| main.rs:0:0:0:0 | main.rs | 4 |
3+
| my_macro.rs:0:0:0:0 | my_macro.rs | 4 |
4+
| does_not_compile.rs:0:0:0:0 | does_not_compile.rs | 3 |
5+
| error.rs:0:0:0:0 | error.rs | 2 |
66
| lib.rs:0:0:0:0 | lib.rs | 0 |
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
| Lines of code | 6806 |
2-
| Lines of user code | 16 |
1+
| Lines of code | 13437 |
2+
| Lines of user code | 24 |

0 commit comments

Comments
 (0)