TL;DR
This paper introduces a novel dataset of "intentional clone refactoring" by analyzing commit messages in the Linux kernel. They found that explicitly documented clone refactoring is rare, accounting for less than 1% of observed clone removal and inconsistent change events, suggesting that most clone evolution is not explicitly tracked or motivated by clone management.
What Problem Does This Paper Address?
Software developers often create duplicate code, known as "code clones." Managing these clones is crucial for software maintenance, as they can lead to inconsistencies and bugs. Researchers have studied clone refactoring history to understand how developers deal with clones. However, a significant challenge is distinguishing between refactoring that intentionally addresses code duplication and refactoring that might coincidentally remove a clone but was motivated by other goals (e.g., performance optimization). This paper tackles the problem of identifying and quantifying intentional clone refactoring to gain a more accurate understanding of how developers manage code clones in practice.
Methods
The authors developed a method to identify intentional clone refactoring by leveraging version control system commit messages. They specifically searched for commits in the Linux kernel's Git repository that contained keywords related to "duplicated code." To avoid false positives, they excluded generic terms like "clone" which might refer to Git's version control cloning. They then combined this dataset of intentional refactoring commits with results from a clone detection tool (Bauhaus iClones) to analyze the evolution of these identified clones. Their analysis focused on two key clone evolution scenarios: clone fragment removal and inconsistent changes within clone families.
Datasets
The primary dataset used in this paper is derived from the Linux kernel's Git repository, specifically focusing on commits made since 2005. The authors identified 348 commits that explicitly mentioned "duplicated code" in their messages, forming their "intentional clone refactoring" dataset. This dataset was then analyzed in conjunction with clone detection results from the Bauhaus iClones tool applied to 33 minor releases of the Linux kernel, focusing on four major subsystems: arch.powerpc, drivers.infiniband, drivers.usb, and sound.soc.
Key Insights and Ideas
- Intentionality is Rare: The most striking finding is that explicitly documented, intentional clone refactoring is a small fraction of overall clone evolution. This suggests that developers may not always be aware of or explicitly document their efforts to manage code duplication.
- Keyword Choice Matters: The authors highlight the importance of careful keyword selection. Using "duplicated code" proved more effective than broader terms like "clone" which can have ambiguous meanings in a version control context.
- Clone Fragments are Small: Interestingly, clone fragments involved in intentional refactoring were often smaller than the typical minimum threshold (50 tokens) used in many clone detection research settings. This implies that smaller, more localized duplications might be more actively and intentionally managed.
- Implications for Research: The rarity of intentional refactoring suggests that relying solely on observed clone refactoring history might provide a skewed view of clone management practices. This work opens avenues for more nuanced research into developer intent and the practicalities of clone management.
Key Results
The study identified 348 commits related to intentional clone refactoring within the Linux kernel. When analyzing clone evolution in four major subsystems, they found that:
- Clone Fragment Removal: Intentional clone refactoring accounted for a very small proportion of all clone fragment removals. For example, in
arch.powerpc, only 4 out of 38,805 removed clone fragments were linked to intentional refactoring. - Inconsistent Changes: Similarly, intentional clone refactoring represented a minor fraction of inconsistent changes within clone families. For instance, in
drivers.usb, only 36 out of 51,221 inconsistent changes were associated with intentional refactoring.
In both scenarios, intentional clone refactoring accounted for fewer than 1% of all detected clone changes across the analyzed subsystems.
Limitations and Future Work
The authors acknowledge that their keyword-based approach to identifying intentional refactoring is a "lower bound" on the actual amount of such refactoring, as not all intentional refactoring might be explicitly documented with the chosen keywords. The study is also limited to four major subsystems of the Linux kernel.
Future work could involve expanding the analysis to more subsystems and other large-scale software projects. Further research could also explore the specific patterns and motivations behind intentional clone refactoring, potentially leading to improved tools for clone management and software quality assessment. The authors suggest that their corpus data offers new research opportunities for understanding cloning in practice.
Summary updated