Improving Semantic Consistency of Variable Names with Use-Flow Graph Analysis

Improving Semantic Consistency of Variable Names with Use-Flow Graph Analysis
复制标题

DOI:
10.1109/apsec53868.2021.00030
复制
发表时间:
2021-12
期刊:
2021 28th Asia-Pacific Software Engineering Conference (APSEC)
影响因子:
--
通讯作者:
Yusuke Shinyama;Yoshitaka Arahori;K. Gondow
Yusuke Shinyama;Yoshitaka Arahori;K. Gondow
中科院分区:
其他
文献类型:
--
作者:
Yusuke Shinyama;Yoshitaka Arahori;K. Gondow

文献摘要

相似文献

一致性是维护源代码的关键之一,因此是一个成功的软件项目。我们提出了一种新的方法提取程序员的意图从源代码的一个大型项目(~ 300 kbps),并检查其变量名的语义一致性。我们的系统学习一个项目特定的命名约定的变量的基础上,其作用完全从源代码,并建议替代方案时,违反其内部一致性。该系统还可以显示为什么要以特定方式命名某个变量的推理。该系统不依赖任何外部知识。我们将我们的方法应用于12个开源项目,并与人类评审员一起评估其结果。我们的系统为1080个实例中的416个(39%)提出了替代变量名称,这些实例被认为比开发人员最初使用的更好。根据结果,我们创建了补丁来纠正不一致的名称,并将其发送给开发人员。三个开源项目采用了它。
Consistency is one of the keys to maintainable source code and hence a successful software project. We propose a novel method of extracting the intent of programmers from source code of a large project (~ 300 kLOC) and checking the semantic consistency of its variable names. Our system learns a project-specific naming convention for variables based on its role solely from source code, and suggest alternatives when it violates its internal consistency. The system can also show the reasoning why a certain variable should be named in a specific way. The system does not rely on any external knowledge. We applied our method to 12 open-source projects and evaluated its results with human reviewers. Our system proposed alternative variable names for 416 out of 1080 (39%) instances that are considered better than ones originally used by the developers. Based on the results, we created patches to correct the inconsistent names and sent them to its developers. Three open-source projects adopted it.