Skip to content

Commit a4e9d6e

Browse files
committed
[metrics] Add top-level spaces in skipped nodes for loc metric
1 parent 236cede commit a4e9d6e

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/sloc.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl SourceLoc for PythonCode {
105105
let start = init(node, stats, is_func_space, is_unit);
106106

107107
match node.kind_id().into() {
108-
Comment | String | DQUOTE | DQUOTE2 | ExpressionStatement | Block => {}
108+
Comment | String | DQUOTE | DQUOTE2 | ExpressionStatement | Block | Module => {}
109109
_ => {
110110
stats.lines.insert(start);
111111
}
@@ -120,7 +120,7 @@ impl SourceLoc for MozjsCode {
120120
let start = init(node, stats, is_func_space, is_unit);
121121

122122
match node.kind_id().into() {
123-
Comment | String | DQUOTE | ExpressionStatement | StatementBlock => {}
123+
Comment | String | DQUOTE | ExpressionStatement | StatementBlock | Program => {}
124124
_ => {
125125
stats.lines.insert(start);
126126
}
@@ -135,7 +135,7 @@ impl SourceLoc for JavascriptCode {
135135
let start = init(node, stats, is_func_space, is_unit);
136136

137137
match node.kind_id().into() {
138-
Comment | String | DQUOTE | ExpressionStatement | StatementBlock => {}
138+
Comment | String | DQUOTE | ExpressionStatement | StatementBlock | Program => {}
139139
_ => {
140140
stats.lines.insert(start);
141141
}
@@ -150,7 +150,7 @@ impl SourceLoc for TypescriptCode {
150150
let start = init(node, stats, is_func_space, is_unit);
151151

152152
match node.kind_id().into() {
153-
Comment | String | DQUOTE | ExpressionStatement | StatementBlock => {}
153+
Comment | String | DQUOTE | ExpressionStatement | StatementBlock | Program => {}
154154
_ => {
155155
stats.lines.insert(start);
156156
}
@@ -165,7 +165,7 @@ impl SourceLoc for TsxCode {
165165
let start = init(node, stats, is_func_space, is_unit);
166166

167167
match node.kind_id().into() {
168-
Comment | String | DQUOTE | ExpressionStatement | StatementBlock => {}
168+
Comment | String | DQUOTE | ExpressionStatement | StatementBlock | Program => {}
169169
_ => {
170170
stats.lines.insert(start);
171171
}

src/web/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ mod tests {
624624
"unique_operands": 1.0,
625625
"unique_operators": 2.0,
626626
"volume": 4.754_887_502_163_468},
627-
"loc": {"cloc": 0.0, "lloc": 3.0, "sloc": 3.0}},
627+
"loc": {"cloc": 1.0, "lloc": 2.0, "sloc": 3.0}},
628628
"name": "test.py",
629629
"spaces": [{"kind": "function",
630630
"start_line": 2,

0 commit comments

Comments
 (0)