Abstract
Despite the widely accepted notion that software metrics like classic McCabe cyclomatic complexity (V(g)) or those provided by tools such as SonarQube (CC Sonar) represent code understandability from the perspective of a typical programmer, the accuracy of these metrics in reflecting perceived code understandability remains uncertain. This paper investigates the complementarity of code complexity metrics using a data-driven approach that incorporates linear and non-linear regression models. To evaluate the complementarity of code metrics, a controlled experiment was conducted with 35 programmers of varying expertise, who read and comprehended a set of programs with varying levels of complexity. The complexity of the programs was initially measured using established metrics, and the cognitive load (CL) of the programmers was captured through electroencephalography (EEG) while they understood the code. Given the controlled conditions of the experiment (free from interruptions or distractions), the cognitive load measured by EEG accurately indicates the mental effort involved in understanding the code. The study found that Halstead metrics (Effort and Difficulty) have a higher correlation with EEG-measured cognitive load (Spearman correlation rs=0.66 and 0.64, respectively) compared to V(g) (rs=0.33) and CC Sonar (rs=0.35). However, no single metric fully captured the complexity perceived by programmers, emphasizing the need for complementary metrics. The results of combining multiple metrics through data-driven regression models significantly improved predictive accuracy, with Gaussian Process Regression achieving a maximum R² of 0.8742. These findings suggest that bridging the gap between static complexity metrics and the cognitive demands of code comprehension requires a hybrid approach that integrates complementary metrics, offering a more holistic view of code understandability.
| Original language | English |
|---|---|
| Article number | 112679 |
| Journal | Journal of Systems and Software |
| Volume | 232 |
| DOIs | |
| Publication status | Published - Feb 2026 |
Keywords
- Code complexity metrics
- Cognitive load
- EEG
- Software quality
Fingerprint
Dive into the research topics of 'Complementarity in software code complexity metrics'. Together they form a unique fingerprint.Press/Media
-
Investigators from Faculty of Applied Sciences Release New Data on Computers (Complementarity In Software Code Complexity Metrics)
2/02/26
1 item of Media coverage
Press/Media
Cite this
- APA
- Author
- BIBTEX
- Harvard
- Standard
- RIS
- Vancouver