Improve cognitive_complexity lint's warning.

Adds the value of complexity limit set for the lint
to the warning.

Fixes #4466

Signed-off-by: Victor Polevoy <fx@thefx.co>
This commit is contained in:
Victor Polevoy
2019-08-29 10:56:13 +02:00
parent 4c8a941daf
commit 87ef86ef5a
3 changed files with 26 additions and 22 deletions

View File

@@ -100,7 +100,11 @@ impl CognitiveComplexity {
cx,
COGNITIVE_COMPLEXITY,
span,
&format!("the function has a cognitive complexity of {}", rust_cc),
&format!(
"the function has a cognitive complexity of ({}/{})",
rust_cc,
self.limit.limit()
),
"you could split it up into multiple smaller functions",
);
}