Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust: Improve lines-of-code counts. #17588

Merged
merged 10 commits into from
Oct 2, 2024
3 changes: 2 additions & 1 deletion rust/ql/lib/codeql/files/FileSystem.qll
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ class File extends Container, Impl::File {
result =
count(int line |
exists(AstNode node, Location loc |
not node instanceof SourceFile and loc = node.getLocation()
not node instanceof SourceFile and
loc = node.getLocation()
|
node.getFile() = this and
line = [loc.getStartLine(), loc.getEndLine()] and
Expand Down
2 changes: 1 addition & 1 deletion rust/ql/test/query-tests/diagnostics/LinesOfCode.expected
Original file line number Diff line number Diff line change
@@ -1 +1 @@
| 48 |
| 49 |
Original file line number Diff line number Diff line change
@@ -1 +1 @@
| 48 |
| 49 |
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
| my_struct.rs:0:0:0:0 | my_struct.rs | 21 |
| main.rs:0:0:0:0 | main.rs | 8 |
| my_macro.rs:0:0:0:0 | my_macro.rs | 8 |
| main.rs:0:0:0:0 | main.rs | 7 |
| lib.rs:0:0:0:0 | lib.rs | 6 |
| does_not_compile.rs:0:0:0:0 | does_not_compile.rs | 3 |
| error.rs:0:0:0:0 | error.rs | 3 |
6 changes: 3 additions & 3 deletions rust/ql/test/query-tests/diagnostics/SummaryStats.expected
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
| Elements extracted | 204 |
| Elements extracted | 211 |
| Elements unextracted | 0 |
| Files extracted | 6 |
| Lines of code extracted | 48 |
| Lines of user code extracted | 48 |
| Lines of code extracted | 49 |
| Lines of user code extracted | 49 |
2 changes: 1 addition & 1 deletion rust/ql/test/query-tests/diagnostics/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mod my_macro;
// another comment

fn main() { // another comment
//println!("Hello, world!"); // currently causes consistency issues
println!("Hello, world!");

my_struct::my_func();
my_macro::my_func();
Expand Down
2 changes: 1 addition & 1 deletion rust/ql/test/query-tests/diagnostics/my_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

macro_rules! myMacro {
() => {
//println!("Hello, world!"); // currently causes consistency issues
println!("Hello, world!");
};
}

Expand Down
Loading