Levels of logic complexity and conditions seem to be unbalanced

Software EleganceCode Complexity

Why you should care

Managing software complexity is an art of balancing the different natures of complexity that code can exhibit. Ensuring that logical operators are not too frequently complex within logical conditions is one way to help developers spend more time adding new features instead of trying to figure out how to interpret when a condition is applicable. Ideally, simple combinations of logical operators makes the code easier to understand, adapt and fix, even if the source file is complex overall.

Business Impacts

Acceleration
5362

CAST Recommendations

In the context of this code insight, some IFs could be added in order to reduce the abnormally high ratio between logical operators and conditions.  Associated with another code insight that exclusively focuses on conditions complexity (Cyclomatic Complexity), these two complexity insights will help you find a good compromise between operators’ complexity and conditional complexity.

How we detect

This code insight counts the number of logical operators (AND and OR) and compares it to the number of condition expressions (IF, WHILE, FOR). Based on ratios and thresholds CAST has determined by thousands of complex software, Highlight counts penalty points for the scanned source file.

5362

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.

See featuresHow it works