Troubleshooting of Sonar issue: Difference between revisions
Jump to navigation
Jump to search
→How to resolve "Refactor this function to reduce its Cognitive Complexity from 17 to the 15 allowed."
| Line 83: | Line 83: | ||
* with {{kbd | key=<nowiki> </nowiki>}} (four whitespaces) | * with {{kbd | key=<nowiki> </nowiki>}} (four whitespaces) | ||
== How to resolve "Refactor this function to reduce its Cognitive Complexity from | == How to resolve "Refactor this function to reduce its Cognitive Complexity from XX to the 15 allowed." == | ||
Possible solution | Possible solution<ref>[https://www.compozelabs.com/post/avoiding-and-fix-spaghetti-code How to fix your spaghetti code (and avoid it in the first place) | Compoze Labs]</ref> | ||
* Created smaller, more specific functions (following [https://en.wikipedia.org/wiki/Single-responsibility_principle Single Responsibility Principle]) to handle specific parts of the logic. | * Created smaller, more specific functions (following [https://en.wikipedia.org/wiki/Single-responsibility_principle Single Responsibility Principle]) to handle specific parts of the logic. Use these secondary functions to make the main function easier to read and understand. | ||
* Avoid nested conditionals | |||
* Simplify boolean expressions | |||
== Unresolved issues == | == Unresolved issues == | ||