Skip to content

Commit

Permalink
Auto merge of #6009 - Ryan1729:show-line_count-and-max_lines-in-too_m…
Browse files Browse the repository at this point in the history
…any_lines-lint-message, r=phansch

Show line count and max lines in too_many_lines lint message

This PR adds the current amount of lines and the current maximum number of lines in the message for the `too_many_lines` lint, in a similar way as the `too_many_arguments` lint currently does.

changelog: show the line count and the maximum lines in the message for the `too_many_lines` lint.
  • Loading branch information
bors committed Sep 5, 2020
2 parents f253dd0 + 9e7ce9d commit 3cecdc9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
7 changes: 6 additions & 1 deletion clippy_lints/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,12 @@ impl<'tcx> Functions {
}

if line_count > self.max_lines {
span_lint(cx, TOO_MANY_LINES, span, "this function has a large number of lines")
span_lint(
cx,
TOO_MANY_LINES,
span,
&format!("this function has too many lines ({}/{})", line_count, self.max_lines),
)
}
}

Expand Down
4 changes: 2 additions & 2 deletions tests/ui-toml/functions_maxlines/test.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error: this function has a large number of lines
error: this function has too many lines (2/1)
--> $DIR/test.rs:18:1
|
LL | / fn too_many_lines() {
Expand All @@ -9,7 +9,7 @@ LL | | }
|
= note: `-D clippy::too-many-lines` implied by `-D warnings`

error: this function has a large number of lines
error: this function has too many lines (2/1)
--> $DIR/test.rs:38:1
|
LL | / fn comment_before_code() {
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/functions_maxlines.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error: this function has a large number of lines
error: this function has too many lines (102/100)
--> $DIR/functions_maxlines.rs:58:1
|
LL | / fn bad_lines() {
Expand Down

0 comments on commit 3cecdc9

Please sign in to comment.