Skip to content

Commit d3c5072

Browse files
committed
Rust: exclude Comment nodes from lines of code counts
1 parent 45d3d38 commit d3c5072

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ private import codeql.Locations
44
private import codeql.util.FileSystem
55
private import codeql.rust.elements.SourceFile
66
private import codeql.rust.elements.AstNode
7+
private import codeql.rust.elements.Comment
78

89
private module Input implements InputSig {
910
abstract class ContainerBase extends @container {
@@ -44,7 +45,9 @@ class File extends Container, Impl::File {
4445
result =
4546
count(int line |
4647
exists(AstNode node, Location loc |
47-
not node instanceof SourceFile and loc = node.getLocation()
48+
not node instanceof Comment and
49+
not node instanceof SourceFile and
50+
loc = node.getLocation()
4851
|
4952
node.getFile() = this and
5053
line = [loc.getStartLine(), loc.getEndLine()] and

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
| Elements extracted | 204 |
1+
| Elements extracted | 210 |
22
| Elements unextracted | 0 |
33
| Files extracted | 6 |
44
| Lines of code extracted | 48 |

0 commit comments

Comments
 (0)