论文标题

使用使用流图分析改善可变名称的语义一致性

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

论文作者

Shinyama, Yusuke, Arahori, Yoshitaka, Gondow, Katsuhiko

论文摘要

一致性是可维护源代码的关键之一,因此是一个成功的软件项目。我们提出了一种新颖的方法,可以从大型项目的源代码(〜300KLOC)中提取程序员的意图并检查其变量名称的语义一致性。我们的系统仅根据源代码的角色来学习针对变量的特定项目命名公约,并在违反其内部一致性时建议替代方案。该系统还可以说明为什么应以特定方式命名某个变量的原因。该系统不依赖任何外部知识。我们将方法应用于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 (~300kLOC) 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.

扫码加入交流群

加入微信交流群

微信交流群二维码

扫码加入学术交流群,获取更多资源