Is Refactoring Always a Good Egg? Exploring the Interconnection Between Bugs and Refactorings
Autor: | Amirreza Bagheri, Heged��s, P��ter |
---|---|
Jazyk: | angličtina |
Rok vydání: | 2022 |
Předmět: | |
DOI: | 10.5281/zenodo.6381328 |
Popis: | Bug fixing and code refactoring are two distinct maintenance actions with different goals. While bug fixing is a corrective change that eliminates a defect from the program, refactoring targets improving the internal quality (i.e., maintainability) of a software system without changing its functionality. Best practices and common intuition suggest that these code actions should not be mixed in a single code change. Furthermore, as refactoring aims for improving quality without functional changes, we would expect that refactoring code changes will not be sources of bugs. Nonetheless, empirical studies show that none of the above hypotheses are necessarily true in practice. In this paper, we empirically investigate the interconnection between bug-related and refactoring code changes using the SmartSHARK dataset. Our goal is to explore how often bug fixes and refactorings co-occur in a single commit (tangled changes) and whether refactoring changes themselves might induce bugs into the system. We found that it is not uncommon to have tangled commits of bug fixes and refactorings; 21% of bug-fixing commits include at least one type of refactoring on average. What is even more shocking is that 54% of bug-inducing commits also contain code refactoring changes. For instance, 10% (652 occurrences) of the Change Variable Type refactorings in the dataset appear in bug-inducing commits that make up 7.9% of the total inducing commits. RQ1. How common it is that a bug-fixing commit contains refactoring changes as well? Our hypothesis is that bug-fixes should be independent changes not including any other types of code modifications. However, previous studies [27], [28] suggest that in practice, commits often contain tangled code changes. Therefore, we investigate how common it is that developers perform refactoring actions tangled together with bug-fixes. RQ2. Do refactoring operations appear in code modifications inducing bugs? We investigate if refactoring activities may lead to introducing bugs in the system (i.e., we can detect a bug fixing activity on the refactored code later in the commit history). For this, we analyzed if the commits marked as 'bug inducing' in the dataset also contain refactoring actions or not. RQ3. What are the most common refactoring types appearing in bug inducing commits? Finally, if we find that bug inducing changes may contain refactoring code modifications as well, we explore what are the most common types of refactorings we observe. It can help us understand what are the most 'dangerous' refactoring types where the developers need to pay special attention not to introduce bugs alongside with the modifications. |
Databáze: | OpenAIRE |
Externí odkaz: |