An Exploratory Study on the Lifecycle of Code Clones During Code Review - Uchoa, Italo; Sousa, Denis; Paixao, Matheus; Maia, Pedro; Uchôa, Anderson; Ragkhitwetsagul, Chaiyong (Anais do Simpósio Brasileiro de Engenharia de Software (SBES), 2025)
The Modern Code Review (MCR) process is iterative and asynchronous, enabling early identification of several issues during software development. Overall, code reviewconsists of inspecting code before merging it into the codebase. Code clones are code fragments that are copied and reused across different (or the same) codebases, often with minor changes. Developers must be aware of code clones in their projects, as issues in a cloned fragment may cause adjustments in all related clones, which can significantly impact the project’s maintainability. Nevertheless, there is still a gap in research addressing the presence and behavior of code clones during code review. By leveraging the CROP dataset (with over 28k code reviews and 80k revisions) and the Siamese clone detector, we identified 27,656 relevant code clones that underwent code review in 6 different software systems. A manual validation of a representative sample indicated a predominance of Type-I (46.74%) and Type-III (45.3%) clones. Based on the clones’ lifecycle within the review, we categorized the reviews into Single and Recurring, according to how the clones are introduced and/or removed during the review process. We identified 224 reviews for which clones appear in a single review (Single) and 1,258 reviews for which clones appear in multiple revisions (Recurring). Additionally, 236 code reviews lie at the intersection of Recurring and Single code reviews. To deepen the analysis, we introduced two metrics, Duration and Distance, to assess how clones are introduced or removed during the review. We observed that, on average, clones are often introduced at the beginning of the code review, commonly surviving the review process and being merged into the codebase.