Large language models (LLMs) have gained widespread popularity and have steadily improved over time, enabling software developers to use them for various code-related tasks. One common task is code refactoring, where the LLM suggests changes for the developer to apply to their code to improve quality attributes such as readability or maintainability. While current research focuses on evaluating LLM-generated refactoring suggestions, there is a limited understanding of how developers apply these suggestions in practice. To explore this, we analyze 169 GitHub commits where developers refactor their code based on a ChatGPT conversation linked in the commit message. We found that developers mostly accept and use the suggestions without modifications. When changes are made, they are mostly major and fall into five different patterns that depend on the refactoring activity, the developer's prompt, and the validity of the response from ChatGPT.
翻译:大语言模型(LLM)已获得广泛普及并随时间稳步改进,使软件开发者能够将其用于各类代码相关任务。其中一项常见任务是代码重构,即LLM提出修改建议供开发者应用于代码,以改善可读性或可维护性等质量属性。当前研究主要聚焦于评估LLM生成的重构建议,但关于开发者如何在实践中应用这些建议的理解仍十分有限。为探究此问题,我们分析了169个GitHub提交记录,其中开发者基于提交信息中链接的ChatGPT对话对其代码进行重构。我们发现开发者大多直接接受并使用未作修改的建议。当发生修改时,这些修改主要为重大修改,并遵循五种不同模式,这些模式取决于重构活动、开发者的提示语以及ChatGPT回复的有效性。