arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2002.06392cs.SE
收藏

推荐使用基于路径的代码表示的Move方法重构

Recommendation of Move Method Refactoring Using Path-Based Representation of Code

Zarina Kurbatova, Ivan Veselov, Yaroslav Golubev, Timofey Bryksin

摘要:

软件重构在提高代码质量方面起着重要的作用。最流行的重构类型之一是移动方法重构。当一个方法依赖于其他类的成员多于依赖于它自己的原始类时,通常会应用它。已经提出了几种方法来自动推荐Move Method重构。它们中的大多数是基于几何学的,并且具有某些限制(例如,它们取决于度量的选择和手动定义的阈值)。在本文中,我们提出了一种方法,建议移动方法重构的基础上,基于路径的代码表示称为code2vec,能够捕获代码片段的语法结构和语义信息。我们使用这种代码表示训练一个机器学习分类器,建议将方法移动到更合适的类。我们在两个公开的数据集上评估了该方法:一个是知名开源项目的手动编译数据集,另一个是自动注入代码气味实例的合成数据集。结果表明,我们的方法是能够推荐准确的重构机会,并优于JDeodorant和JMove,这是最先进的工具,在这个领域。

英文摘要:

Software refactoring plays an important role in increasing code quality. One of the most popular refactoring types is the Move Method refactoring. It is usually applied when a method depends more on members of other classes than on its own original class. Several approaches have been proposed to recommend Move Method refactoring automatically. Most of them are based on heuristics and have certain limitations (e.g., they depend on the selection of metrics and manually-defined thresholds). In this paper, we propose an approach to recommend Move Method refactoring based on a path-based representation of code called code2vec that is able to capture the syntactic structure and semantic information of a code fragment. We use this code representation to train a machine learning classifier suggesting to move methods to more appropriate classes. We evaluate the approach on two publicly available datasets: a manually compiled dataset of well-known open-source projects and a synthetic dataset with automatically injected code smell instances. The results show that our approach is capable of recommending accurate refactoring opportunities and outperforms JDeodorant and JMove, which are state of the art tools in this field.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑