Skip to content

Cognitive complexity doesn't work for async functions #9300

Closed
@JosuGZ

Description

@JosuGZ

Summary

I've been trying the cognitive complexity lint and I have found that on async functions it doesn't work. Here is an example, clippy will complain about complex, but not about complex_async:

#![allow(clippy::all)]
#![deny(clippy::cognitive_complexity)]

pub async fn complex_async() {
    let a = 0;
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
}

pub fn complex() {
    let a = 0;
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
    if a == 0 {}
}

Metadata

Metadata

Assignees

Labels

C-bugCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn't

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions