计算机科学 ›› 2025, Vol. 52 ›› Issue (12): 32-39.doi: 10.11896/jsjkx.241200007

• 计算机软件&体系架构 • 上一篇    下一篇

支持类型敏感场景的跨过程代码依恋检测

厉剑豪, 白瑶瑶, 密杰, 张迎周, 曹文龙, 王栋, 王刚   

  1. 南京邮电大学计算机学院 南京 210023
  • 收稿日期:2024-12-02 修回日期:2025-03-28 出版日期:2025-12-15 发布日期:2025-12-09
  • 通讯作者: 张迎周(zhangyz@njupt.edu.cn)
  • 作者简介:(lijh0410@163.com)
  • 基金资助:
    国家自然科学基金(62272214)

Cross-procedure Feature Envy Detection Supporting Type-sensitive Scenarios

LI Jianhao, BAI Yaoyao, MI Jie, ZHANG Yingzhou, CAO Wenlong, WANG Dong, WANG Gang   

  1. School of Computer Science, Nanjing University of Posts and Telecommunications, Nanjing 210023, China
  • Received:2024-12-02 Revised:2025-03-28 Published:2025-12-15 Online:2025-12-09
  • About author:LI Jianhao,born in 2001,postgraduate,is a member of CCF(No.E4926G).His main research interest is program ana-lysis.
    ZHANG Yingzhou,born in 1978,professor,is a member of CCF(No.16845S).His main research interests include software formal analysis,program slicing,service computing and functional programming.
  • Supported by:
    This work was supported by the National Natural Science Foundation of China(62272214).

摘要: 代码依恋现象的存在会影响系统的稳定性和可维护性。目前的代码依恋检测方法均未考虑对象类型的敏感性,导致检测精度较低。为解决此问题,提出一种基于高阶函数的过程间代码依恋检测方法。该方法根据预定义的代码依恋度量规则,将过程内带参数的局部性引用比的计算过程抽象为可复用的高阶函数式摘要;过程间检测时,在方法调用点处取出目标方法的高阶代码依恋检测摘要,并根据形实参对应关系将形参的实际类型代入摘要中,计算得到最终的局部性引用比集合,基于该集合来检测代码依恋现象以及对应的依恋集。整合了部分Java项目作为基准测试集,选取IntelliJDeodorant和IDE Inspection工具进行对比实验,结果表明:提出的方法在检测依恋实例的精度上较IDE Inspection提高了16.6%,比IntelliJDeodorant提高了1.3倍;在检测依恋集的精度上较IDE Inspection提高了37.2%,比IntelliJDeodorant提高了1.6倍。

关键词: 代码依恋检测, 类型敏感, 过程间, 高阶函数, 函数摘要, Java

Abstract: The existence of feature envy phenomena can affect the stability and maintainability of the system.Current feature envy detection methods fail to consider the sensitivity of object types,leading to low detection accuracy.To address this issue,an inter-procedure feature envy detection method based on higher-order function is proposed.The method stores the computation process of the local reference ratios within a procedure with parameters as a summary in the form of higher-order function,according to predefined feature envy measurement rules.During inter-procedure detection,it retrieves the higher-order feature envy detection summary of the target method at the method call site.Based on the correlation between formal and actual parameters,the actual types of the formal parameters are substituted into the summary to compute the final local reference ratios set,which is used to detect the presence of feature envy and corresponding envy sets.The paper integrates several Java projects as a benchmark test set and selects the IntelliJDeodorant and IDE Inspection tools for comparison experiments.Results show that the proposed methodimproves detection accuracy for envy instances by 16.6% over IDE Inspection and by 1.3 times over IntelliJDeodorant.In terms of envy sets detection accuracy,it improves by 37.2% over IDE Inspection and by 1.6 times over IntelliJDeodorant.

Key words: Feature envy detection, Type-sensitive, Inter-procedure, High-order function, Function summary, Java

中图分类号: 

  • TP311
[1]FOWLER M,BECK K,BRANT J,et al.Refactoring:improving the design of existing code [M].Massachusetts:Addison-Wesley,1999.
[2]TAN T,MA X X,XU C,et al.Overview of Java Pointer Analysis[J].Journal of Computer Research and Development,2023,60(2):274-293.
[3]HU Z,HUGHES J,WANG M.How functional programming mattered[J].National Science Review,2015,2(3):349-370.
[4]ZHANG Y Z,ZHANG W F.Haskell:A Modern Purely Functional Programming Language[J].Journal of Nanjing University of Posts and Telecommunications(Natural Science),2007(4):13-18,23.
[5]FOKAEFS M,TSANTAILS N,CHATZIGEORGIOU A.JDe-odorant:Identication and Removal of Feature Envy Bad Smells[C]//Proceedings of the 23rd IEEE International Conference on Software Maintenance.IEEE,2007:519-520.
[6]SALES V,TERRA R,MIRANDA L F,et al.Recommending Move MethodRefactorings Using Dependency Sets[C]//Proceedings of the 20th Working Conference on Reverse Engineering.IEEE,2013:232-241.
[7]LIU D D,ZHAO F Y.Research on feature envy detection and refactoring[J].Electronic Science and Technology,2016,29(11):70-73.
[8]CHEN W K,LIU C H,LI B H.A feature envy detection method based on dataflow analysis[C]//IEEE 42nd Annual Computer Software and Applications Conference.IEEE,2018:14-19.
[9]SKIPINA M,SLIVKA J,LUBURIC N,et al.Automaticdetection of Feature Envy and Data Class code smells using machine learning[J].Expert Systems With Applications,2024,243:122855.
[10]PRIYAMBADHA B,KATAYAMA T,KITA Y,et al.Detection of Blob and Feature Envy Smells in a Class Diagram using Class’s Features[J].Journal of Robotics,Networking and Artificial Life,2022,9(1):43-48.
[11]LIU B,LIU H,LI G J,et al.Deep Learning Based Feature Envy Detection Boosted by Real-World Examples[C]//Proceedings of the 31st ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering.ACM,2023:908-920.
[12]AL-FRAIHAT D,SHARRAB Y,AL-GHUWAIRI A R,et al.Detecting and resolving feature envy throughautomatedmachine learning and move method refactoring[J].International Journal of Electrical & Computer Engineering,2024,4(2):2330-2343.
[13]YU D J,XU Y H,WENG L H,et al.Efficient feature envy detection and refactoring based ongraphneural network[J].Automated Software Engineering,2025,32(1).
[14]GRUJIC K G,PROKIC S,KOVACEVIC A,et al.MachineLearning Approaches for Code Smell Detection:A Systematic Literature Review[J/OL].Social Science Research Network,2022.https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4299859.
[15]LEWOWSKI T,MADEYSKI L.Code smells detection using artificial intelligence techniques:A business-driven systematic review[M]//Studies in Systems,Decision and Control.2021:285-319.
[16]BLOCH J.Effective Java[M].Beijing:Posts & Telecom Press,2024.
Viewed
Full text


Abstract

Cited

  Shared   
  Discussed   
No Suggested Reading articles found!