13 lines
669 B
Plaintext
13 lines
669 B
Plaintext
Reducing cognitive complexity can be challenging. +
|
|
Here are a few suggestions:
|
|
|
|
* **Extract complex conditions in a new function.** +
|
|
Mixed operators in condition will increase complexity.
|
|
Extracting the condition in a new function with an appropriate name will reduce cognitive load.
|
|
* **Break down large functions.** +
|
|
Large functions can be hard to understand and maintain.
|
|
If a function is doing too many things, consider breaking it down into smaller, more manageable functions.
|
|
Each function should have a single responsibility.
|
|
* **Avoid deep nesting by returning early.** +
|
|
To avoid the nesting of conditions, process exceptional cases first and return early.
|