Skip to content
Advertisement

Tag: cognitive-complexity

How to reduce cognitive complexity of nested if

I have an if statement set up like this I’m wondering if I can lower the cognitive complexity? Right now this is a score of 4. Answer I would say the best way to lower the cognitive complexity is to use functions. This is similar to @GuerricP original answer, but handles the multiple case of do somthing 2 eg. This

Advertisement