论文标题
认知复杂性作为源代码可理解性的经验验证
An Empirical Validation of Cognitive Complexity as a Measure of Source Code Understandability
论文作者
论文摘要
背景:开发人员花费大量时间在理解源代码上。静态代码分析工具可以引起对开发人员难以理解的代码的关注。但是,大多数发现基于非验证指标,这可能会导致混乱和代码,这很难理解,无法识别。 目的:在这项工作中,我们验证了一个称为认知复杂性的度量,该指标是经过明确设计的,旨在衡量代码可理解性,并且由于其集成在众所周知的静态代码分析工具中,因此已广泛使用。 方法:我们进行了系统的文献搜索,以从测量代码可理解性的研究中获取数据集。这样,我们获得了大约24,000个427代码段的可理解性评估。我们计算了这些测量值与相应的度量值的相关性,并通过荟萃分析从统计上总结了相关系数。 结果:认知复杂性与理解时间和可理解性的主观评分正相关。该度量与理解任务的正确性和生理措施相关性的结果混合了结果。 结论:这是第一个经过验证且唯一的基于代码的度量标准,它至少能够反映代码可理解性的某些方面。此外,由于其方法,这项工作表明,当前以许多不同方式衡量了代码理解,我们也不知道它们是如何相关的。这使得很难比较单个研究的结果以及开发一个指标,以衡量其所有方面的代码理解。
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 the correlation coefficients through a meta-analysis. Results: Cognitive Complexity positively correlates with comprehension time and subjective ratings of understandability. The metric showed mixed results for the correlation with the correctness of comprehension tasks and with physiological measures. Conclusions: It is the first validated and solely code-based metric which is able to reflect at least some aspects of code understandability. Moreover, due to its methodology, this work shows that code understanding is currently measured in many different ways, which we also do not know how they are related. This makes it difficult to compare the results of individual studies as well as to develop a metric that measures code understanding in all its facets.