An empirical study on bug propagation through code cloning - Mondal, Manishankar; Roy, Banani; Roy, Chanchal K.; Schneider, Kevin A. (The Journal of systems and software, 2019)
•Around 18.42% of the buggy code clones are involved with bug propagation.•Near-miss clones have a higher tendency of bug-propagation than identical clones.•Method clones are mostly involved with bug-propagation.•Severe bugs can sometimes get propagated through code cloning.•Copying a previously committed code fragment is safer than copying an uncommitted fragment. Code clones are identical or nearly similar code fragments in a code-base. According to the existing studies, code clones are directly related to bugs. Code cloning, creating code clones, is suspected to propagate temporarily hidden bugs from one code fragment to another. However, there is no study on the intensity of bug-propagation through code cloning. In this paper, we define two clone evolutionary patterns that reasonably indicate bug propagation through code cloning. By analyzing software evolution history, we identify those code clones that evolved following the bug propagation patterns. According to our study on thousands of commits of seven subject systems, overall 18.42% of the clone fragments that experience bug-fixes contain propagated bugs. Type-3 clones are primarily involved with bug-propagation. Bug propagation is more likely to occur in the clone fragments that are created in the same commit rather than in different commits. Moreover, code clones residing in the same file have a higher possibility of containing propagated bugs compared to those residing in different files. Severe bugs can sometimes get propagated through code cloning. Automatic support for immediately identifying occurrences of bug-propagation can be beneficial for software maintenance. Our findings are important for prioritizing code clones for management.