The objective of this research project is to assess the impact of ChatGPT on code quality. We specifically analyzed ChatGPT's impact on the quality of code by assessing certain quality attributes and determining if the behavior was preserved. Additionally, we investigated ChatGPT's effectiveness in providing documentation in the refactored code segments. We split our research into three research questions and this project was done over 10 weeks, including two weekly team meetings. The version of ChatGPT we used was ChatGPT 3.5.
While past studies explore both the limitations and capabilities of ChatGPT from a software engineering perspective, they do not explore its abilities in refactoring code. By researching ChatGPT’s abilities to refactor code, there is the opportunity for great potential in optimizing both the quality of code, as well as productivity with respect to the time and cost it takes to conduct the refactoring. Furthermore, ChatGPT has the potential to revolutionize software engineering as it has capabilities that other AI lack. ChatGPT’s ability to remember multi-message chats and have human-like conversations is extraordinary. Therefore, studying ChatGPT’s capabilities is crucial because it is a new tool that can lead to additional significant advancements in software engineering. ChatGPT is helping technology evolve and it is important to analyze its effect. By determining both the abilities and limitations of using ChatGPT to refactor code, the software engineering community will be able to enhance their understanding and utilization of the platform by gaining valuable insights from our research.
ChatGPT has shown great potential in the field of software engineering with its ability to generate code. Yet, ChatGPT’s ability to interpret code has been deemed unreliable and faulty, which causes concern for the platform’s ability to properly refactor code. To confront this concern, we carried out a study to assess ChatGPT’s abilities and limitations in refactoring code. We divided the study into two parts: if ChatGPT will refactor code, and if the refactored code preserves the behavior of the original code segments. We focused our research specifically on eight quality attributes to use when prompting ChatGPT to refactor our dataset of 40 Java code segments. After collecting the refactored code segments from ChatGPT, as well as data on whether the behavior was preserved, we ran the refactored code through PMD, a source code analyzer, to find programming flaws. We also tested ChatGPT’s accuracy in generating commit messages for the refactored code and analyzed the difference between the results of each quality attribute. We conclude that ChatGPT is able to provide many useful refactoring changes that can improve the code quality which is crucial, but our results also show that ChatGPT can be unpredictable in its responses which threatens the reliability of ChatGPT. Additionally, we found that the quality attributes play a crucial role in the refactoring methods of ChatGPT, encouraging future research to explore ways of manipulating ChatGPT to only use specific methods and techniques in refactoring.