RS.CLIPPY.COGNITIVE_COMPLEXITY

@eval_always = true

This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: cognitive_complexity. Copyright ©2025 The Rust Team. All rights reserved.

What it does

Checks for methods with high cognitive complexity.

Why is this bad?

Methods of high cognitive complexity tend to be hard to both read and maintain. Also LLVM will tend to optimize small methods better.

Known problems

Sometimes it's hard to find a way to reduce the complexity.

Example

You'll see it when you get the warning.

Past names

  • cyclomatic_complexity

Configuration

  • cognitive-complexity-threshold: The maximum cognitive complexity a function can have

    (default: 25)