diff options
| author | bors <bors@rust-lang.org> | 2020-09-05 06:05:29 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-09-05 06:05:29 +0000 |
| commit | 3cecdc9cddde084acb747a1eb23262496e15dbea (patch) | |
| tree | 39905e08fe0d0c6ed2c6d1eb980615bd59ef8710 | |
| parent | f253dd06f91a496580d30dea45b669beaa9e1def (diff) | |
| parent | 9e7ce9d3851426f59ec98eabee7f113e4fd18198 (diff) | |
| download | rust-3cecdc9cddde084acb747a1eb23262496e15dbea.tar.gz rust-3cecdc9cddde084acb747a1eb23262496e15dbea.zip | |
Auto merge of #6009 - Ryan1729:show-line_count-and-max_lines-in-too_many_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.
| -rw-r--r-- | clippy_lints/src/functions.rs | 7 | ||||
| -rw-r--r-- | tests/ui-toml/functions_maxlines/test.stderr | 4 | ||||
| -rw-r--r-- | tests/ui/functions_maxlines.stderr | 2 |
3 files changed, 9 insertions, 4 deletions
diff --git a/clippy_lints/src/functions.rs b/clippy_lints/src/functions.rs index 89fde1d509d..50b39cf4ea7 100644 --- a/clippy_lints/src/functions.rs +++ b/clippy_lints/src/functions.rs @@ -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), + ) } } diff --git a/tests/ui-toml/functions_maxlines/test.stderr b/tests/ui-toml/functions_maxlines/test.stderr index fb12257021a..a27ce945ca5 100644 --- a/tests/ui-toml/functions_maxlines/test.stderr +++ b/tests/ui-toml/functions_maxlines/test.stderr @@ -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() { @@ -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() { diff --git a/tests/ui/functions_maxlines.stderr b/tests/ui/functions_maxlines.stderr index c640c82d6d7..dc6c8ba2f15 100644 --- a/tests/ui/functions_maxlines.stderr +++ b/tests/ui/functions_maxlines.stderr @@ -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() { |
