International Journal of Electrical and Computer Engineering (IJECE) Vol. 14, No. 2, April 2024, pp. 2330~2343 ISSN: 2088-8708, DOI: 10.11591/ijece.v14i2.pp2330-2343 2330 Journal homepage: http://ijece.iaescore.com Detecting and resolving feature envy through automated machine learning and move method refactoring Dimah Al-Fraihat 1 , Yousef Sharrab 2 , Abdel-Rahman Al-Ghuwairi 3 , Majed AlElaimat 3 , Maram Alzaidi 4 1 Department of Software Engineering, Faculty of Information Technology, Isra University, Amman, Jordan 2 Department of Data Science and Artificial Intelligence, Faculty of Information Technology, Isra University, Amman, Jordan 3 Department of Software Engineering, Faculty of Prince Al-Hussein Bin Abdallah II for Information Technology, The Hashemite University, Zarqa, Jordan 4 Department of Computer Science, College of Computers and Information Technology, Taif University, Taif, Kingdom of Saudi Arabia Article Info ABSTRACT Article history: Received Oct 9, 2023 Revised Dec 30, 2023 Accepted Jan 9, 2024 Efficiently identifying and resolving code smells enhances software project quality. This paper presents a novel solution, utilizing automated machine learning (AutoML) techniques, to detect code smells and apply move method refactoring. By evaluating code metrics before and after refactoring, we assessed its impact on coupling, complexity, and cohesion. Key contributions of this research include a unique dataset for code smell classification and the development of models using AutoGluon for optimal performance. Furthermore, the study identifies the top 20 influential features in classifying feature envy, a well-known code smell, stemming from excessive reliance on external classes. We also explored how move method refactoring addresses feature envy, revealing reduced coupling and complexity, and improved cohesion, ultimately enhancing code quality. In summary, this research offers an empirical, data-driven approach, integrating AutoML and move method refactoring to optimize software project quality. Insights gained shed light on the benefits of refactoring on code quality and the significance of specific features in detecting feature envy. Future research can expand to explore additional refactoring techniques and a broader range of code metrics, advancing software engineering practices and standards. Keywords: Automated machine learning Code smell Feature envy Move method Refactoring Software quality This is an open access article under the CC BY-SA license. Corresponding Author: Dimah Al-Fraihat Department of Software Engineering, Faculty of Information Technology, Isra University Amman, 11622, Jordan Email: d.fraihat@iu.edu.jo 1. INTRODUCTION Refactoring is the process of enhancing the readability and usability of software code while preserving its functionality [1]. Changes must be made to the code without changing how it functions. The main goals of refactoring are to make the code more understandable and to make it easier to update-either the design or the actual code-without requiring as much work [2]. Refactoring is advantageous for several reasons. Firstly, it improves code understandability which makes it simpler to maintain and lowers the likelihood of introducing errors [3]. Furthermore, refactoring promotes code reuse by enabling its implementation in different projects or different sections of a program [4]. Refactoring further makes code simpler, which makes it easier to manage as well as more flexible in the long run. In addition to reducing technical debt, this helps to avoid problems and inefficiencies [5]. Another benefit is that by improving the