An Empirical Validation of Cognitive Complexity as a Measure of Source Code Understandability
Marvin Mu\~noz Bar\'on, Marvin Wyrich, Stefan Wagner

TL;DR
This study validates Cognitive Complexity as a reliable metric for assessing code understandability, showing positive correlations with comprehension time and subjective ratings, thus supporting its use in static analysis tools.
Contribution
It provides the first validation of Cognitive Complexity as a code-based measure of understandability through a comprehensive meta-analysis.
Findings
Cognitive Complexity correlates with comprehension time.
It correlates with subjective understandability ratings.
Mixed results for correctness and physiological measures.
Abstract
Background: Developers spend a lot of their time on understanding source code. Static code analysis tools can draw attention to code that is difficult for developers to understand. However, most of the findings are based on non-validated metrics, which can lead to confusion and code, that is hard to understand, not being identified. Aims: In this work, we validate a metric called Cognitive Complexity which was explicitly designed to measure code understandability and which is already widely used due to its integration in well-known static code analysis tools. Method: We conducted a systematic literature search to obtain data sets from studies which measured code understandability. This way we obtained about 24,000 understandability evaluations of 427 code snippets. We calculated the correlations of these measurements with the corresponding metric values and statistically summarized…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
