Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show line count and max lines in too_many_lines lint message #6009

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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