Why you should care
Having complex conditional expressions in your software might slow down your development team to quickly evaluate if and how the code will be run within these conditions. In addition, if conditions are misunderstood because there are too complex (especially when additional native functions like “!empty” or “!isset” makes the whole condition even more complex) , it might create unexpected behaviors during the QA phase or, more badly, in production if the logic path that verifies a condition hasn’t been followed by testers.
Business Impacts
Complex conditional operations can cause loss of time in an attempt to understand the code. It also decreases the innovation capabilities of the code. These factors can make the code unsuitable for clients.
CAST Recommendations
References
How we detect
Example of a simple conditional expression:
(a && b && c && d && e && f) is not complex, because there is no distinct operators.
Example of a complex conditional expression:
((a && b && c) || (d && e || f)) is complex.
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.