rust-lang / rust-lang/rust-clippy
website: cognitive complexity does insufficiently explain method
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
What it does
Checks for methods with high cognitive complexity.
What kind of methology is used in the code is completely missing. Is this method implemented? https://github.com/rust-lang/rust-clippy/issues/3793
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.
The first statement is unfalsifiable due to missing definition. LLVM and most compilers do graph-based optimisations, so a long switch-case is no problem for LLVM to handle. Which is in contrast to what cognitive complexity applies as method (from my experience).
Known problems
Sometimes it’s hard to find a way to reduce the complexity.
Search on GitHub
It is not possible to disable unless one annotates it in every file. Many problem domains are inherently complex and splitting the code does not make the problem easier. As it works currently, it does not take into account the code graph of the control structure in a proper way and thus is insufficient.
Example
No. You’ll see it when you get the warning.
Configuration
This lint has the following configuration variables:
cognitive-complexity-threshold: u64: The maximum cognitive complexity a function can have (defaults to 25).
Great, a configuration without understanding how they work.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the cognitive-complexity lint description, its configuration variable, and the discussion linked as rust-lang/rust-clippy#3793. Document the methodology and limitations clearly enough that users understand what the warning measures, why it exists, and how configuration affects it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 42/100