Rust: Improve getNumberOfLinesOfCode (in particular, it will now include the closing of blocks { } ).

This commit is contained in:
Geoffrey White
2024-09-13 18:20:23 +01:00
parent 0d5c25b400
commit 551c4e83f4
5 changed files with 16 additions and 10 deletions

View File

@@ -40,6 +40,12 @@ class File extends Container, Impl::File {
*/
int getNumberOfLinesOfCode() {
result =
count(int line | exists(Location loc | loc.getFile() = this and loc.getStartLine() = line and not loc instanceof EmptyLocation))
count(int line |
exists(Location loc |
loc.getFile() = this and
line = [loc.getStartLine(), loc.getEndLine()] and
not loc instanceof EmptyLocation
)
)
}
}

View File

@@ -1 +1 @@
| 6806 |
| 13437 |

View File

@@ -1 +1 @@
| 16 |
| 24 |

View File

@@ -1,6 +1,6 @@
| my_struct.rs:0:0:0:0 | my_struct.rs | 8 |
| main.rs:0:0:0:0 | main.rs | 3 |
| does_not_compile.rs:0:0:0:0 | does_not_compile.rs | 2 |
| my_macro.rs:0:0:0:0 | my_macro.rs | 2 |
| error.rs:0:0:0:0 | error.rs | 1 |
| my_struct.rs:0:0:0:0 | my_struct.rs | 11 |
| main.rs:0:0:0:0 | main.rs | 4 |
| my_macro.rs:0:0:0:0 | my_macro.rs | 4 |
| does_not_compile.rs:0:0:0:0 | does_not_compile.rs | 3 |
| error.rs:0:0:0:0 | error.rs | 2 |
| lib.rs:0:0:0:0 | lib.rs | 0 |

View File

@@ -1,2 +1,2 @@
| Lines of code | 6806 |
| Lines of user code | 16 |
| Lines of code | 13437 |
| Lines of user code | 24 |