in src/metrics/cognitive.rs [793:835]
fn rust_sequence_same_booleans() {
check_metrics::<RustParser>(
"fn f() {
if a && b && true { // +2 (+1 sequence of &&)
println!(\"test\");
}
}",
"foo.rs",
|metric| {
insta::assert_json_snapshot!(
metric.cognitive,
@r###"
{
"sum": 2.0,
"average": 2.0,
"min": 0.0,
"max": 2.0
}"###
);
},
);
check_metrics::<RustParser>(
"fn f() {
if a || b || c || d { // +2 (+1 sequence of ||)
println!(\"test\");
}
}",
"foo.rs",
|metric| {
insta::assert_json_snapshot!(
metric.cognitive,
@r###"
{
"sum": 2.0,
"average": 2.0,
"min": 0.0,
"max": 2.0
}"###
);
},
);
}