Skip to content

Commit

Permalink
Do not count Rust functions in if statements for lloc
Browse files Browse the repository at this point in the history
  • Loading branch information
Luni-4 committed Mar 19, 2021
1 parent 299b1db commit 20d1fd8
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/metrics/loc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,9 @@ impl Loc for RustCode {
| LetDeclaration
| WhileExpression
| WhileLetExpression
| ForExpression,
| ForExpression
| IfExpression
| IfLetExpression,
Block
) == 0
{
Expand Down Expand Up @@ -661,6 +663,18 @@ mod tests {
);
}

#[test]
fn rust_function_in_if_lloc() {
check_metrics!(
"if foo() {} // +1
if let Some(a) = foo() {} // +1",
"foo.rs",
RustParser,
loc,
[(lloc, 2, usize)]
);
}

#[test]
fn rust_closure_expression_lloc() {
check_metrics!(
Expand Down

0 comments on commit 20d1fd8

Please sign in to comment.