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 条
[1]  
Bahdanau D, 2016, Arxiv, DOI arXiv:1409.0473
[2]   InferCode: Self-Supervised Learning of Code Representations by Predicting Subtrees [J].
Bui, Nghi D. Q. ;
Yu, Yijun ;
Jiang, Lingxiao .
2021 IEEE/ACM 43RD INTERNATIONAL CONFERENCE ON SOFTWARE ENGINEERING (ICSE 2021), 2021, :1186-1197
[3]   SMOTE: Synthetic minority over-sampling technique [J].
Chawla, Nitesh V. ;
Bowyer, Kevin W. ;
Hall, Lawrence O. ;
Kegelmeyer, W. Philip .
2002, American Association for Artificial Intelligence (16)
[4]  
Cunningham W., 1993, OOPS Messenger, V4, P29
[5]  
Devlin J, 2019, 2019 CONFERENCE OF THE NORTH AMERICAN CHAPTER OF THE ASSOCIATION FOR COMPUTATIONAL LINGUISTICS: HUMAN LANGUAGE TECHNOLOGIES (NAACL HLT 2019), VOL. 1, P4171
[6]  
Fowler M., 1999, AW OBJ TECHNOL S
[7]  
Graves A, 2012, STUD COMPUT INTELL, V385, P1, DOI [10.1162/neco.1997.9.1.1, 10.1007/978-3-642-24797-2]
[8]   Deep semantic-Based Feature Envy Identification [J].
Guo, Xueliang ;
Shi, Chongyang ;
Jiang, He .
11TH ASIA-PACIFIC SYMPOSIUM ON INTERNETWARE (INTERNETWARE 2019), 2019,
[9]   How Far Have We Progressed in Identifying Self-admitted Technical Debts? A Comprehensive Empirical Study [J].
Guo, Zhaoqiang ;
Liu, Shiran ;
Liu, Jinping ;
Li, Yanhui ;
Chen, Lin ;
Lu, Hongmin ;
Zhou, Yuming .
ACM TRANSACTIONS ON SOFTWARE ENGINEERING AND METHODOLOGY, 2021, 30 (04)
[10]   A multi-label classification approach for detecting test smells over java']java projects [J].
Hadj-Kacem, Mouna ;
Bouassida, Nadia .
JOURNAL OF KING SAUD UNIVERSITY-COMPUTER AND INFORMATION SCIENCES, 2022, 34 (10) :8692-8701