Skip to content

Too many lines fails to detect a long function #4364

@iddm

Description

@iddm

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions