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

Too many lines fails to detect a long function #4364

Closed
iddm opened this issue Aug 9, 2019 · 0 comments
Closed

Too many lines fails to detect a long function #4364

iddm opened this issue Aug 9, 2019 · 0 comments
Labels
C-bug Category: Clippy is not doing the correct thing

Comments

@iddm
Copy link
Contributor

iddm commented Aug 9, 2019

The lint does not detect the long function which is the second main in the example, however, it detects the problem in the first main.

The clippy.toml:

too-many-lines-threshold = 2

The code:

#![deny(clippy::all)]
#![deny(clippy::pedantic)]

fn f() -> u16 {
    0
}

// This fails the check (should).
//fn main() {
//    println!("Hello, world!");
//    println!("Hello,1 world!");
//    println!("Hello,12 world!");
//}

// This passes (shouldn't).
fn main() {
    println!("Hello, world! {}", f());
    println!("Hello,1 world!");
    println!("Hello,12 world!");
    println!("Hello1, world!");
    println!("Hello,2 world!");
    println!("Hello, 5world!");
    println!("Hello, w6orld!");
}

clippy 0.0.212 (b029042 2019-07-12)

I was able to reproduce the problem with a single println!("Hello, world! {}", f()) statement - every line after such a statement is not counted.

@flip1995 flip1995 added A-musing C-bug Category: Clippy is not doing the correct thing labels Aug 9, 2019
@bors bors closed this as completed in 0ae1a69 Sep 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing
Projects
None yet
Development

No branches or pull requests

2 participants