2019-01-13 15:26:20 -06:00
|
|
|
#![warn(clippy::too_many_lines)]
|
2022-03-17 18:53:28 -05:00
|
|
|
#![allow(clippy::let_unit_value)]
|
2019-01-13 15:26:20 -06:00
|
|
|
|
|
|
|
// This function should be considered one line.
|
|
|
|
fn many_comments_but_one_line_of_code() {
|
|
|
|
/* println!("This is good."); */
|
|
|
|
// println!("This is good.");
|
|
|
|
/* */ // println!("This is good.");
|
|
|
|
/* */ // println!("This is good.");
|
|
|
|
/* */ // println!("This is good.");
|
|
|
|
/* */ // println!("This is good.");
|
|
|
|
/* println!("This is good.");
|
|
|
|
println!("This is good.");
|
|
|
|
println!("This is good."); */
|
|
|
|
println!("This is good.");
|
|
|
|
}
|
|
|
|
|
|
|
|
// This should be considered two and a fail.
|
|
|
|
fn too_many_lines() {
|
|
|
|
println!("This is bad.");
|
|
|
|
println!("This is bad.");
|
|
|
|
}
|
|
|
|
|
2021-08-05 08:38:57 -05:00
|
|
|
// This should only fail once (#7517).
|
|
|
|
async fn async_too_many_lines() {
|
|
|
|
println!("This is bad.");
|
|
|
|
println!("This is bad.");
|
|
|
|
}
|
|
|
|
|
|
|
|
// This should fail only once, without failing on the closure.
|
|
|
|
fn closure_too_many_lines() {
|
|
|
|
let _ = {
|
|
|
|
println!("This is bad.");
|
|
|
|
println!("This is bad.");
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-01-13 15:26:20 -06:00
|
|
|
// This should be considered one line.
|
2019-02-01 12:19:55 -06:00
|
|
|
#[rustfmt::skip]
|
2019-01-13 15:26:20 -06:00
|
|
|
fn comment_starts_after_code() {
|
|
|
|
let _ = 5; /* closing comment. */ /*
|
|
|
|
this line shouldn't be counted theoretically.
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
// This should be considered one line.
|
|
|
|
fn comment_after_code() {
|
|
|
|
let _ = 5; /* this line should get counted once. */
|
|
|
|
}
|
|
|
|
|
|
|
|
// This should fail since it is technically two lines.
|
2019-02-01 12:19:55 -06:00
|
|
|
#[rustfmt::skip]
|
2019-01-13 15:26:20 -06:00
|
|
|
fn comment_before_code() {
|
|
|
|
let _ = "test";
|
|
|
|
/* This comment extends to the front of
|
2019-04-04 04:15:30 -05:00
|
|
|
the code but this line should still count. */ let _ = 5;
|
2019-01-13 15:26:20 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// This should be considered one line.
|
|
|
|
fn main() {}
|