diff --git a/src/metrics/cognitive.rs b/src/metrics/cognitive.rs index c44e027b9..2f51b34b3 100644 --- a/src/metrics/cognitive.rs +++ b/src/metrics/cognitive.rs @@ -222,7 +222,7 @@ impl Cognitive for PythonCode { ExceptClause => { increment(stats); } - ExpressionList | ExpressionStatement => { + ExpressionList | ExpressionStatement | Tuple => { stats.boolean_seq.reset(); } NotOperator => { @@ -497,6 +497,19 @@ mod tests { ); } + #[test] + fn python_tuple() { + check_metrics!( + "def f(a, b): + return \"%s%s\" % (a and \"Get\" or \"Set\", b)", + "foo.py", + PythonParser, + cognitive, + [(cognitive, 2, usize)], + [(cognitive_average, 2.0)] + ); + } + #[test] fn python_elif_function() { check_metrics!(