Abstract

A number of authors hypothesize and experimentally confirm that Cyclomatic Complexity (CC) has a very strong correlation with Lines of Code (LOC), justifying the use of LOC in place of CC. Others report on a moderate correlation and advocate for the use of both metrics. These studies have, for the most part, studied production code, and we suspect different results may be observed for test code. With 40 different, large open-source subjects and five subjects from industry partners, we collected metric values for LOC, CC and Halstead Effort (HE) and measured their correlation. In test code, contrary to production code, there exist a very weak (or almost no) correlation between (a) LOC and CC, and weak (nearly moderate) correlation for (b) HE and CC, and (c) LOC and HE. We therefore argue and propose that the level of correlation depends on at least three factors namely: the kind of code (i.e., production code vs test code), the kind of software (open-source vs industry) and the kind of metric (LOC, CC, HE). Given the weak monotonicity between CC, LOC and HE we observe, we aspire to challenge the viewpoint that CC and Halstead metrics are redundant with LOC, as some studies suggest, at least on test code. We therefore advocate for using CC over LOC (or both, or cyclomatic density) when studying test code, as CC is perceived to better reflect cognitive complexity, numerical complexity, interdependency and code refactoring that cannot be accounted for simply by LOC.

Full Text
Paper version not known

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call

Disclaimer: All third-party content on this website/platform is and will remain the property of their respective owners and is provided on "as is" basis without any warranties, express or implied. Use of third-party content does not indicate any affiliation, sponsorship with or endorsement by them. Any references to third-party content is to identify the corresponding services and shall be considered fair use under The CopyrightLaw.