EM-Assist: Safe Automated ExtractMethod Refactoring with LLMs
Open Access
- 10 July 2024
- conference paper
- Published by Association for Computing Machinery (ACM)
- p. 582-586
Abstract
Excessively long methods, loaded with multiple responsibilities, are challenging to understand, debug, reuse, and maintain. The solution lies in the widely recognized Extract Method refactoring. While the application of this refactoring is supported in modern IDEs, recommending which code fragments to extract has been the topic of many research tools. However, they often struggle to replicate real-world developer practices, resulting in recommendations that do not align with what a human developer would do in real life. To address this issue, we introduce EM-Assist, an IntelliJ IDEA plugin that uses LLMs to generate refactoring suggestions and subsequently validates, enhances, and ranks them. Finally, EM-Assist uses the IntelliJ IDE to apply the user-selected recommendation. In our extensive evaluation of 1,752 real-world refactorings that actually took place in open-source projects, EM-Assist’s recall rate was 53.4% among its top-5 recommendations, compared to 39.4% for the previous best-in-class tool that relies solely on static analysis. Moreover, we conducted a usability survey with 18 industrial developers and 94.4% gave a positive rating.Keywords
All Related Versions
Funding Information
- NSF (CNS-1941898)
This publication has 22 references indexed in Scilit:
- Discovering repetitive code changes in ML systems2021
- RefactoringMiner 2.0IEEE Transactions on Software Engineering, 2020
- Identifying Extract Method Refactoring Opportunities Based on Functional RelevanceIEEE Transactions on Software Engineering, 2016
- Why we refactor? confessions of GitHub contributors2016
- Recommending automated extract method refactorings2014
- A Comparative Study of Manual and Automated Refactorings2013
- Identification of extract method refactoring opportunities for the decomposition of methodsJournal of Systems and Software, 2011
- Identifying Fragments to be Extracted from Long Methods2009
- Software complexity and maintenance costsCommunications of the ACM, 1993
- Usability Testing1993