paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Three Heads Are Better Than One: Suggesting Move Method Refactoring Opportunities with Inter-class Code Entity Dependency Enhanced Hybrid Hypergraph Neural Network

三个头胜过一个:基于类间代码实体依赖增强的混合超图神经网络推荐 Move Method 重构机会
ASE Proceedings of the 39th IEEE/ACM International Conference on Automated Software Engineering2024匹配度 3/10 · 论文属于机器学习辅助代码重构推荐(Move Method),虽结合超图神经网络与LLM,但目标不是静态分析/形式化验证,也不涉及浮点或贝叶斯程序分析,与画像核心方向交叉有限。引用 4 inbox
Di Cui, Jiaqi Wang, Qiangqiang Wang, Peng Ji, Minglang Qiao, Yutong Zhao, Jingzhao Hu, Luqiao Wang, Qingshan Li
crossref: 2026-09-12

AI 速览

一句话:提出 HMove,用类间代码实体依赖超图与混合超图神经网络结合大语言模型,推荐 Move Method 重构机会。

方法实现于错误类会造成 feature envy,使类间耦合增加、难以维护。现有 Move Method 重构工具多用硬编码度量和启发式阈值,侧重方法与类的成对相关性,忽略多个代码实体间的复杂依赖,建议可能偏离开发者需求。本文提出 HMove:构建类间代码实体依赖超图,用预训练代码模型赋予实体属性,输入混合超图神经网络训练,并结合大语言模型形成重构建议系统。在大规模数据集训练、两个真实数据集评估,相较9个先进工具,precision提升27.8%、recall提升2.5%、F1提升18.5%,68%参与者认为更有用。

问题
方法实现于错误类会导致 feature envy 和类间耦合增加;现有 Move Method 重构推荐依赖硬编码度量和成对相关性,忽略多个代码实体间的复杂依赖。
方法
构建类间代码实体依赖超图,用预训练代码模型为实体赋属性,输入混合超图神经网络训练,并结合大语言模型构建重构建议系统。
评估
在大规模数据集上训练,在两个真实数据集上评估;相较9个SOTA重构工具,precision、recall、F1分别提升27.8%、2.5%、18.5%,且68%参与者认为更有用。
原文摘要(Abstract)

Methods implemented in incorrect classes will cause excessive reliance on other classes than their own, known as a typical code smell symptom: feature envy, which makes it difficult to maintain increased coupling between classes. Addressing this issue, several Move Method refactoring tools have been proposed, employing a two-phase process: identifying misplaced methods to move and appropriate classes to receive, and implementing the mechanics of refactoring. These tools traditionally use hard-coded metrics to measure correlations between movable methods and target classes and apply heuristic thresholds or trained classifiers to unearth refactoring opportunities. Yet, these approaches predominantly illuminate pairwise correlations between methods and classes while overlooking the complex and complicated dependencies binding multiple code entities within these methods/classes that are prevalent in real-world cases. This narrow focus can lead to refactoring suggestions that may diverge from developers' actual needs. To bridge this gap, our paper leverages the concept of inter-class code entity dependency hypergraph to model complicated dependency relationships involving multiple code entities within various methods/classes and proposes a hypergraph learning-based approach to suggest Move Method refactoring opportunities named HMove. We first construct inter-class code entity dependency hypergraphs from training samples and assign attributes to entities with a pre-trained code model. All the attributed hypergraphs are fed into a hybrid hypergraph neural network for training. Utilizing this trained neural network alongside a large language model, we construct a refactoring suggestion system. We trained HMove on a large-scale dataset and evaluated it on two real-world datasets. The results show that demonstrates an increase of 27.8% in precision, 2.5% in recall, and 18.5% in f1-measure compared to 9 state-of-the-art refactoring tools, which is more useful for 68% of participants. The results also unveil practical suggestions and new insights that benefit existing feature envy-related refactoring techniques.

链接与引用

DOI 原文 ·

BibTeX
@inproceedings{paperbot8320,
  title = {Three Heads Are Better Than One: Suggesting Move Method Refactoring Opportunities with Inter-class Code Entity Dependency Enhanced Hybrid Hypergraph Neural Network},
  author = {Di Cui and Jiaqi Wang and Qiangqiang Wang and Peng Ji and Minglang Qiao and Yutong Zhao and Jingzhao Hu and Luqiao Wang and Qingshan Li},
  booktitle = {ASE},
  year = {2024},
  doi = {10.1145/3691620.3695068}
}