Bug Replication in Code Clones: An Empirical Study

Code clones are exactly or nearly similar code fragments in the code-base of a software system. Existing studies show that clones are directly related to bugs and inconsistencies in the code-base. Code cloning (making code clones) is suspected to be responsible for replicating bugs in the code fragments. However, there is no study on the possibilities of bug-replication through cloning process. Such a study can help us discover ways of minimizing bug-replication. Focusing on this we conduct an empirical study on the intensities of bug-replication in the code clones of the major clone-types: Type 1, Type 2, and Type 3. According to our investigation on thousands of revisions of six diverse subject systems written in two different programming languages, C and Java, a considerable proportion (i.e., up to 10%) of the code clones can contain replicated bugs. Both Type 2 and Type 3 clones have higher tendencies of having replicated bugs compared to Type 1 clones. Thus, Type 2 and Type 3 clones are more important from clone management perspectives. The extent of bug-replication in the buggy clone classes is generally very high (i.e., 100% in most of the cases). We also find that overall 55% of all the bugs experienced by the code clones can be replicated bugs. Our study shows that replication of bugs through cloning is a common phenomenon. Clone fragments having method-calls and if-conditions should be considered for refactoring with high priorities, because such clone fragments have high possibilities of containing replicated bugs. We believe that our findings are important for better maintenance of software systems, in particular, systems with code clones.

[1]  Mark Harman,et al.  Searching for better configurations: a rigorous approach to clone evaluation , 2013, ESEC/FSE 2013.

[2]  Martin P. Robillard,et al.  Clonetracker: tool support for code clone management , 2008, ICSE '08.

[3]  Chanchal Kumar Roy,et al.  Conflict-aware optimal scheduling of prioritised code clone refactoring , 2013, IET Softw..

[4]  Michel Wermelinger,et al.  Tracking clones' imprint , 2010, IWSC '10.

[5]  Manishankar Mondal,et al.  A comparative study on the bug-proneness of different types of code clones , 2015, 2015 IEEE International Conference on Software Maintenance and Evolution (ICSME).

[6]  Rob Miller,et al.  Interactive Simultaneous Editing of Multiple Text Regions , 2001, USENIX ATC, General Track.

[7]  Chanchal Kumar Roy,et al.  Evaluating Modern Clone Detection Tools , 2014, 2014 IEEE International Conference on Software Maintenance and Evolution.

[8]  Audris Mockus,et al.  Identifying reasons for software changes using historic databases , 2000, Proceedings 2000 International Conference on Software Maintenance.

[9]  Jeffrey C. Carver,et al.  Measuring the Efficacy of Code Clone Information in a Bug Localization Task: An Empirical Study , 2011, 2011 International Symposium on Empirical Software Engineering and Measurement.

[10]  Manishankar Mondal,et al.  Connectivity of co-changed method groups: a case study on open source systems , 2012, CASCON.

[11]  Jens Krinke,et al.  Is Cloned Code More Stable than Non-cloned Code? , 2008, 2008 Eighth IEEE International Working Conference on Source Code Analysis and Manipulation.

[12]  Manishankar Mondal,et al.  Prediction and ranking of co-change candidates for clones , 2014, MSR 2014.

[13]  Yuanyuan Zhou,et al.  CP-Miner: A Tool for Finding Copy-paste and Related Bugs in Operating System Code , 2004, OSDI.

[14]  Michel Wermelinger,et al.  Assessing the effect of clones on changeability , 2008, 2008 IEEE International Conference on Software Maintenance.

[15]  Daniela Steidl,et al.  Feature-based detection of bugs in clones , 2013, 2013 7th International Workshop on Software Clones (IWSC).

[16]  Nils Göde,et al.  Clone Stability , 2011, 2011 15th European Conference on Software Maintenance and Reengineering.

[17]  Rainer Koschke,et al.  Frequency and risks of changes to clones , 2011, 2011 33rd International Conference on Software Engineering (ICSE).

[18]  Manishankar Mondal,et al.  Late Propagation in Near-Miss Clones: An Empirical Study , 2014, Electron. Commun. Eur. Assoc. Softw. Sci. Technol..

[19]  Manishankar Mondal,et al.  An empirical study on clone stability , 2012, SIAP.

[20]  Manishankar Mondal,et al.  Automatic Identification of Important Clones for Refactoring and Tracking , 2014, 2014 IEEE 14th International Working Conference on Source Code Analysis and Manipulation.

[21]  Zhendong Su,et al.  DECKARD: Scalable and Accurate Tree-Based Detection of Code Clones , 2007, 29th International Conference on Software Engineering (ICSE'07).

[22]  Michael W. Godfrey,et al.  “Cloning considered harmful” considered harmful: patterns of cloning in software , 2008, Empirical Software Engineering.

[23]  Rainer Koschke,et al.  Software Clone Management Towards Industrial Application (Dagstuhl Seminar 12071) , 2012, Dagstuhl Reports.

[24]  Andrew Begel,et al.  Managing Duplicated Code with Linked Editing , 2004, 2004 IEEE Symposium on Visual Languages - Human Centric Computing.

[25]  Chanchal Kumar Roy,et al.  A Mutation/Injection-Based Automatic Framework for Evaluating Code Clone Detection Tools , 2009, 2009 International Conference on Software Testing, Verification, and Validation Workshops.

[26]  Ying Zou,et al.  Studying the Impact of Clones on Software Defects , 2010, 2010 17th Working Conference on Reverse Engineering.

[27]  Martin P. Robillard,et al.  Tracking Code Clones in Evolving Software , 2007, 29th International Conference on Software Engineering (ICSE'07).

[28]  Manishankar Mondal,et al.  Comparative stability of cloned and non-cloned code: an empirical study , 2012, SAC '12.

[29]  Chanchal K. Roy,et al.  A Survey on Software Clone Detection Research , 2007 .

[30]  Zhendong Su,et al.  Context-based detection of clone-related bugs , 2007, ESEC-FSE '07.

[31]  Foutse Khomh,et al.  Late propagation in software clones , 2011, 2011 27th IEEE International Conference on Software Maintenance (ICSM).

[32]  Jens Krinke,et al.  Is cloned code older than non-cloned code? , 2011, IWSC '11.

[33]  Premkumar T. Devanbu,et al.  Clones: what is that smell? , 2010, 2010 7th IEEE Working Conference on Mining Software Repositories (MSR 2010).

[34]  Manishankar Mondal,et al.  SPCP-Miner: A tool for mining code clones that are important for refactoring or tracking , 2015, 2015 IEEE 22nd International Conference on Software Analysis, Evolution, and Reengineering (SANER).

[35]  Shinji Kusumoto,et al.  Is duplicate code more frequently modified than non-duplicate code in software evolution?: an empirical study on open source software , 2010, IWPSE-EVOL '10.

[36]  Manishankar Mondal,et al.  Automatic ranking of clones for refactoring through mining association rules , 2014, 2014 Software Evolution Week - IEEE Conference on Software Maintenance, Reengineering, and Reverse Engineering (CSMR-WCRE).

[37]  Chanchal Kumar Roy,et al.  The NiCad Clone Detector , 2011, 2011 IEEE 19th International Conference on Program Comprehension.

[38]  Daqing Hou,et al.  CReN: a tool for tracking copy-and-paste code clones and renaming identifiers consistently in the IDE , 2007, eclipse '07.

[39]  Elmar Jürgens,et al.  Do code clones matter? , 2009, 2009 IEEE 31st International Conference on Software Engineering.

[40]  Chanchal Kumar Roy,et al.  Detection and analysis of near-miss software clones , 2009, 2009 IEEE International Conference on Software Maintenance.

[41]  Miryung Kim,et al.  An empirical study of code clone genealogies , 2005, ESEC/FSE-13.

[42]  Chanchal Kumar Roy,et al.  The vision of software clone management: Past, present, and future (Keynote paper) , 2014, 2014 Software Evolution Week - IEEE Conference on Software Maintenance, Reengineering, and Reverse Engineering (CSMR-WCRE).

[43]  Shinji Kusumoto,et al.  Experience of finding inconsistently-changed bugs in code clones of mobile software , 2012, 2012 6th International Workshop on Software Clones (IWSC).

[44]  Lerina Aversano,et al.  An empirical study on the maintenance of source code clones , 2010, Empirical Software Engineering.

[45]  Jens Krinke,et al.  A Study of Consistent and Inconsistent Changes to Code Clones , 2007, 14th Working Conference on Reverse Engineering (WCRE 2007).

[46]  Chanchal Kumar Roy,et al.  Comparison and evaluation of code clone detection techniques and tools: A qualitative approach , 2009, Sci. Comput. Program..

[47]  Maninder Singh,et al.  Software clone detection: A systematic review , 2013, Inf. Softw. Technol..

[48]  Chanchal Kumar Roy,et al.  NICAD: Accurate Detection of Near-Miss Intentional Clones Using Flexible Pretty-Printing and Code Normalization , 2008, 2008 16th IEEE International Conference on Program Comprehension.

[49]  Foutse Khomh,et al.  An empirical study of faults in late propagation clone genealogies , 2013, J. Softw. Evol. Process..

[50]  Michael D. Ernst,et al.  CBCD: Cloned buggy code detector , 2012, 2012 34th International Conference on Software Engineering (ICSE).

[51]  Foutse Khomh,et al.  An empirical study of the fault-proneness of clone mutation and clone migration , 2013, 2013 10th Working Conference on Mining Software Repositories (MSR).

[52]  Chanchal Kumar Roy,et al.  Conflict-Aware Optimal Scheduling of Code Clone Refactoring: A Constraint Programming Approach , 2011, 2011 IEEE 19th International Conference on Program Comprehension.

[53]  Lerina Aversano,et al.  How Clones are Maintained: An Empirical Study , 2007, 11th European Conference on Software Maintenance and Reengineering (CSMR'07).