Rule-directed code clone synchronization

Code clones are prevalent in software systems due to many factors in software development. Detecting code clones and managing consistency between them along code evolution can be very useful for reducing clone-related bugs and maintenance costs. Despite some early attempts at detecting code clones and managing the consistency between them, the state-of-the-art tool can only handle simple code clones whose structures are identical or quite similar. However, existing empirical studies show that clones can have quite different structures with their evolution, which can easily go beyond the capability of the state-of-the-art tool. In this paper, we propose CCSync, a novel, rule-directed approach, which paves the structure differences between the code clones and synchronizes them even when code clones become quite different in their structures. The key steps of this approach are, given two code clones, to (1) extract a synchronization rule from the relationship between the clones, and (2) once one code fragment is updated, propagate the modifications to the other following the synchronization rule. We have implemented a tool for CCSync and evaluated its effectiveness on five Java projects. Our results shows that there are many code clones suitable for synchronization, and our tool achieves precisions of up to 92% and recalls of up to 84%. In particular, more than 76% of our generated revisions are identical with manual revisions.

[1]  Yinxing Xue,et al.  Detecting and Summarizing Differences across Multiple Instances of Code Clones , 2013 .

[2]  Miryung Kim,et al.  A field study of refactoring challenges and benefits , 2012, SIGSOFT FSE.

[3]  Tao Xie,et al.  An Empirical Study on Evolution of API Documentation , 2011, FASE.

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

[5]  Zhenchang Xing,et al.  Towards contextual and on-demand code clone management by continuous monitoring , 2013, 2013 28th IEEE/ACM International Conference on Automated Software Engineering (ASE).

[6]  Jianjun Zhao,et al.  Supporting Selective Undo for Refactoring , 2016, 2016 IEEE 23rd International Conference on Software Analysis, Evolution, and Reengineering (SANER).

[7]  Anh Tuan Nguyen,et al.  Statistical learning approach for mining API usage mappings for code migration , 2014, ASE.

[8]  Lu Zhang,et al.  Can I clone this piece of code here? , 2012, 2012 Proceedings of the 27th IEEE/ACM International Conference on Automated Software Engineering.

[9]  Renato De Mori,et al.  Pattern matching for clone and concept detection , 2004, Automated Software Engineering.

[10]  Ettore Merlo,et al.  Assessing the benefits of incorporating function clone detection in a development process , 1997, 1997 Proceedings International Conference on Software Maintenance.

[11]  Elmar Jürgens,et al.  CloneDetective - A workbench for clone detection research , 2009, 2009 IEEE 31st International Conference on Software Engineering.

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

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

[14]  Miryung Kim,et al.  Lase: Locating and applying systematic edits by learning from examples , 2013, 2013 35th International Conference on Software Engineering (ICSE).

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

[16]  Václav Rajlich,et al.  Removing clones from the code , 1999, J. Softw. Maintenance Res. Pract..

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

[18]  Hoan Anh Nguyen,et al.  Clone Management for Evolving Software , 2012, IEEE Transactions on Software Engineering.

[19]  Shinji Kusumoto,et al.  CCFinder: A Multilinguistic Token-Based Code Clone Detection System for Large Scale Source Code , 2002, IEEE Trans. Software Eng..

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

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

[22]  Stan Jarzabek,et al.  Query-based filtering and graphical view generation for clone analysis , 2008, 2008 IEEE International Conference on Software Maintenance.

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

[24]  Miryung Kim,et al.  Interactive Code Review for Systematic Changes , 2015, 2015 IEEE/ACM 37th IEEE International Conference on Software Engineering.

[25]  Stan Jarzabek,et al.  Using Server Pages to Unify Clones in Web Applications: A Trade-Off Analysis , 2007, 29th International Conference on Software Engineering (ICSE'07).

[26]  Zhenchang Xing,et al.  Clone-based and interactive recommendation for modifying pasted code , 2015, ESEC/SIGSOFT FSE.

[27]  Stéphane Ducasse,et al.  A language independent approach for detecting duplicated code , 1999, Proceedings IEEE International Conference on Software Maintenance - 1999 (ICSM'99). 'Software Maintenance for Business Change' (Cat. No.99CB36360).

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

[29]  Giuliano Antoniol,et al.  Comparison and Evaluation of Clone Detection Tools , 2007, IEEE Transactions on Software Engineering.

[30]  Hagen Hagen Is Cloned Code more stable than Non-Cloned Code? , 2008 .

[31]  Yogesh Padmanaban,et al.  Inferring likely mappings between APIs , 2013, 2013 35th International Conference on Software Engineering (ICSE).

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

[33]  Zhenchang Xing,et al.  Cloning practices: Why developers clone and what can be changed , 2012, 2012 28th IEEE International Conference on Software Maintenance (ICSM).

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

[35]  Harald C. Gall,et al.  Change Distilling:Tree Differencing for Fine-Grained Source Code Change Extraction , 2007, IEEE Transactions on Software Engineering.

[36]  Qing Wang,et al.  Mining API mapping for language migration , 2010, 2010 ACM/IEEE 32nd International Conference on Software Engineering.

[37]  Rohit D. Mane Assessing the Refactorability of Software Clones , 2017 .

[38]  Tao Xie,et al.  Exposing Behavioral Differences in Cross-Language API Mapping Relations , 2013, FASE.

[39]  Manishankar Mondal,et al.  A Fine-Grained Analysis on the Evolutionary Coupling of Cloned Code , 2014, 2014 IEEE International Conference on Software Maintenance and Evolution.

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