Too many unconditional branches may end to Spaghetti Code
This code insight counts the number of unconditional branches (e.g. GOTO, continue, break except if it is at end of a ‘case statement’…). Highlight counts penalty points contributing to the Software Resiliency health factor, depending on the density of this pattern you should ideally have in the scanned source file.
Why you should care
Using on a too frequent basis the statements GOTO, continue or break implies a cerebral gymnastic to follow how the program executes, while a good code should be read easily. Having multiple unconditional branches into a single file, when combined with a high amount of code, increases the chances for a develop to introduce new bugs.
CAST recommendations
The good practice is to systematically use braces. Modern development environments can automatically add them when writing new code. Ideally, from a pure maintainability standpoint, the braces should also have a dedicated line for even greater readability.
ReferencesÂ
About CAST and Highlight’s Code Insights
Over the last 25 years, CAST has leveraged unique knowledge on software quality measurement by analyzing thousands of applications and billions of lines of code. Based on this experience and community standards on programming best practices, Highlight implements hundreds of code insights across 15+ technologies to calculate health factors of a software.