Skip to content

Commit

Permalink
Don't consider match stmts, just case only
Browse files Browse the repository at this point in the history
  • Loading branch information
blueraft committed May 24, 2024
1 parent ca4681a commit 10ddbbd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ fn get_complexity_number(stmts: &[Stmt]) -> usize {
complexity += get_complexity_number(orelse);
}
Stmt::Match(ast::StmtMatch { cases, .. }) => {
complexity += 1;
for case in cases {
complexity += 1;
complexity += get_complexity_number(&case.body);
Expand Down Expand Up @@ -442,7 +441,7 @@ def f():
print('bar')
";
let stmts = parse_suite(source)?;
assert_eq!(get_complexity_number(&stmts), 4);
assert_eq!(get_complexity_number(&stmts), 3);
Ok(())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ fn num_branches(stmts: &[Stmt]) -> usize {
.sum::<usize>()
}
Stmt::Match(ast::StmtMatch { cases, .. }) => {
1 + cases.len()
cases.len()
+ cases
.iter()
.map(|case| num_branches(&case.body))
Expand Down Expand Up @@ -282,13 +282,13 @@ else:
#[test]
fn match_case() -> Result<()> {
let source: &str = r"
match x: # 3
match x: # 2
case 0:
pass
case 1:
pass
";
test_helper(source, 3)?;
test_helper(source, 2)?;
Ok(())
}

Expand Down

0 comments on commit 10ddbbd

Please sign in to comment.