构建代码也需要维护:构建系统中重构与技术债务的研究
Build Code Needs Maintenance Too: A Study on Refactoring and Technical Debt in Build Systems
摘要 Abstract
在现代软件工程中,构建系统在源代码转化为软件制品的过程中发挥着至关重要的作用。近期研究探索了构建失败的高层次原因,但很大程度上忽视了构建文件的结构特性。类似于源代码,构建系统也面临技术债务挑战,这些挑战阻碍了其维护和优化。虽然重构常被视为解决源代码技术债务的关键工具,但对于构建代码开发者具体应用的重构更改及其是否有效解决技术债务的研究仍存在显著空白。本文通过分析开源项目中的构建脚本重构,填补这一空白,涵盖广泛使用的Gradle、Ant和Maven构建系统。此外,我们还调查了这些重构是否用于解决构建系统中的技术债务。我们的分析基于\totalCommits个涉及构建文件相关提交的样本进行。我们识别出\totalRefactoringCategories种构建相关的重构,并将其分为\totalCategories个主要类别。这些重构构成了首个基于经验的构建系统重构分类法。进一步地,我们通过手动提交分析和开发者问卷调查,探讨了开发人员如何利用这些重构类型解决技术债务。在此过程中,我们识别出\totalTechnicalDebts种由这些重构解决的技术债务,并讨论了它们与不同重构之间的相关性。最后,我们引入了BuildRefMiner,这是一个基于LLM(大型语言模型)且利用GPT-4o的工具,用于自动化检测构建系统中的重构。我们对其性能进行了评估,发现其在所有构建系统上的F1分数达到了\toolFoneScore。
In modern software engineering, build systems play the crucial role of facilitating the conversion of source code into software artifacts. Recent research has explored high-level causes of build failures, but has largely overlooked the structural properties of build files. Akin to source code, build systems face technical debt challenges that hinder maintenance and optimization. While refactoring is often seen as a key tool for addressing technical debt in source code, there is a significant research gap regarding the specific refactoring changes developers apply to build code and whether these refactorings effectively address technical debt. In this paper, we address this gap by examining refactorings applied to build scripts in open-source projects, covering the widely used build systems of Gradle, Ant, and Maven. Additionally, we investigate whether these refactorings are used to tackle technical debts in build systems. Our analysis was conducted on \totalCommits examined build-file-related commits. We identified \totalRefactoringCategories build-related refactorings, which we divided into \totalCategories main categories. These refactorings are organized into the first empirically derived taxonomy of build system refactorings. Furthermore, we investigate how developers employ these refactoring types to address technical debts via a manual commit-analysis and a developer survey. In this context, we identified \totalTechnicalDebts technical debts addressed by these refactorings and discussed their correlation with the different refactorings. Finally, we introduce BuildRefMiner, an LLM-powered tool leveraging GPT-4o to automate the detection of refactorings within build systems. We evaluated its performance and found that it achieves an F1 score of \toolFoneScore across all build systems.