Troubleshooting of Sonar issue: Difference between revisions
Jump to navigation
Jump to search
m
→How to resolve "Refactor this function to reduce its Cognitive Complexity from XX to the 15 allowed."
| Line 85: | Line 85: | ||
== How to resolve "Refactor this function to reduce its Cognitive Complexity from XX to the 15 allowed." == | == How to resolve "Refactor this function to reduce its Cognitive Complexity from XX to the 15 allowed." == | ||
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> | 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><ref>[https://en.wikipedia.org/wiki/Spaghetti_code Spaghetti code - Wikipedia]</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. Use these secondary functions to make the main function easier to read and understand. | * 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 | * Avoid nested conditionals | ||