Efficient feature envy detection and refactoring based on graph neural network

被引:1
作者
Yu, Dongjin [1 ]
Xu, Yihang [1 ]
Weng, Lehui [1 ]
Chen, Jie [1 ]
Chen, Xin [1 ]
Yang, Quanxin [1 ,2 ]
机构
[1] Hangzhou Dianzi Univ, Coll Comp Sci & Technol, Baiyang St, Hangzhou 310000, Zhejiang, Peoples R China
[2] Xuchang Univ, Sch Informat Engn, Xuchang, Peoples R China
基金
中国国家自然科学基金;
关键词
Code smell; Feature envy; Refactoring; Graph neural network; Metrics;
D O I
10.1007/s10515-024-00476-3
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
As one type of frequently occurring code smells, feature envy negatively affects class cohesion, increases coupling between classes, and thus hampers software maintainability. While progress has been made in feature envy detection, two challenges still persist. Firstly, existing approaches often underutilize method call relationships, resulting in suboptimal detection efficiency. Secondly, they lack the emphasis on feature envy refactoring, which is however the ultimate goal of feature envy detection. To address these challenges, we propose two approaches: SCG (SMOTE Call Graph) and SFFL (Symmetric Feature Fusion Learning). SCG transforms the feature envy detection problem into a binary classification task on a method call graph. It predicts the weights of edges, termed calling strength, to capture the strength of method invocations. Additionally, it converts the method-method call graph into a method-class call graph and recommends the smelly method to the external class with the highest calling strength. As a holistic approach focusing on refactoring feature envy directly, SFFL leverages four heterogeneous graphs to represent method-class relationships. Through Symmetric Feature Fusion Learning, it obtains representations for methods and classes. Link prediction is then employed to generate the refactored method-class ownership graph, which is regarded as the refactored results. Moreover, to address the limitations of existing metrics in accurately evaluating refactoring performance, we introduce three new metrics: precision2\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\textit{precision}_2$$\end{document}, recall2\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\textit{recall}_2$$\end{document} and F1-score2\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\textit{F}_1\text {-score}_2$$\end{document}. Extensive experiments on five open-source projects demonstrate the superiority of SCG and SFFL. The code and dataset used in our study are available at https://github.com/HduDBSI/SCG-SFFL.
引用
收藏
页数:49
相关论文
共 39 条
[11]  
Hamilton WL, 2017, ADV NEUR IN, V30
[12]  
Kingsbury D, 2015, P1, DOI [DOI 10.48550/ARXIV.1412.6980, 10.48550/arXiv.1412.6980, DOI 10.1021/bk-2015-1214.ch001]
[13]  
Kipf ThomasN., 2016, INT C LEARN REPR, DOI DOI 10.48550/ARXIV.1609.02907
[14]  
Le Q.V., 2014, ICML, V14, P1188
[15]   Gradient-based learning applied to document recognition [J].
Lecun, Y ;
Bottou, L ;
Bengio, Y ;
Haffner, P .
PROCEEDINGS OF THE IEEE, 1998, 86 (11) :2278-2324
[16]   Deep Learning Based Feature Envy Detection [J].
Liu, Hui ;
Xu, Zhifeng ;
Zou, Yanzhen .
PROCEEDINGS OF THE 2018 33RD IEEE/ACM INTERNATIONAL CONFERENCE ON AUTOMTED SOFTWARE ENGINEERING (ASE' 18), 2018, :385-396
[17]  
Lozano A, 2015, 2015 IEEE 2ND INTERNATIONAL WORKSHOP ON PATTERNS PROMOTION AND ANTI-PATTERNS PREVENTION (PPAP), P1, DOI 10.1109/PPAP.2015.7076847
[18]   Pre-trained Model Based Feature Envy Detection [J].
Ma, Wenhao ;
Yu, Yaoxiang ;
Ruan, Xiaoming ;
Cai, Bo .
2023 IEEE/ACM 20TH INTERNATIONAL CONFERENCE ON MINING SOFTWARE REPOSITORIES, MSR, 2023, :430-440
[19]   Using Natural Language Processing to Automatically Detect Self-Admitted Technical Debt [J].
Maldonado, Everton da Silva ;
Shihab, Emad ;
Tsantalis, Nikolaos .
IEEE TRANSACTIONS ON SOFTWARE ENGINEERING, 2017, 43 (11) :1044-1062
[20]  
Mikolov T., 2013, DISTRIBUTED REPRESEN, DOI [DOI 10.48550/ARXIV.1301.3781, 10.48550/arXiv.1301.3781]