基于流图分析的变量名语义一致性研究
Improving Semantic Consistency of Variable Names with Use-Flow Graph Analysis
摘要:
一致性是维护源代码的关键之一,因此是一个成功的软件项目。我们提出了一种新的方法提取程序员的意图从一个大型项目(~ 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 (~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.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。