An Efficient Merging Method for Code Clones and Gapped Code Clones Using Software Metrics  
  Authors : Masakazu Takahashi; Yunarso Anang; Reiji Nanba; Yoshimichi Watanabe

 

A program fragment that is created by copying & pasting an existing program is called Code Clone (CC). A program fragment that some instructions are added, deleted, and modified is called Gapped Code Clones (GCC). In general, many CCs and GCCs that exist in the program decrease readability and maintainability of the program. This study proposes an effective detection method of CCs and GCCs that are suitable for merging by calculating software metrics related to the complexity of the control flow, independent from other program portions, and non-dependency of programming language specification. Additionally, this study recommends the merging procedure of CCs and GCCs by calculating software metrics related to the program structure of CCs and GCCs. As a result of the application of the proposed method to the existing programs, it is confirmed that the adequate merging of CCs and GCCs is conducted.

 

Published In : IJCAT Journal Volume 5, Issue 1

Date of Publication : January 2018

Pages : 01-11

Figures :04

Tables :04

Publication Link :An Efficient Merging Method for Code Clones and Gapped Code Clones Using Software Metrics

 

 

 

Masakazu Takahashi : received B.S. degree in 1988 from Rikkyo University, Japan, and M.S. degree in 1998, Ph.D. degree in 2001, both in Systems Management from University of Tsukuba, Japan. He was with Ishikawajima-Harima Heavy Industries Co., Ltd. from 1988 to 2004. He was with Shimane University from 2005 to 2008 and with University of Yamanashi since 2008. He is a professor in University of Yamanashi since 2014. His research interests include software engineering and safety.

Yunarso Anang : received B.E. and M.E. degree in software engineering from University of Yamanashi in 1995 and 1997 respectively, and received Ph.D in engineering also from University of Yamanashi in 2017. He was with SYNC Information System, Inc., Japan from 2000 to 2007 as a senior engineer. He is a lecturer in Institute of Statistics, Indonesia, since 2008. His research interests include software engineering and quality.

Reiji Nanba : received B.E. degree in 1999 from Daiichi Institute of Technology, Japan, and ME degree in 2003 and Ph.D. degree in 2008 from Shimane University, Japan. He was an Assistant Professor in Daiichi Institute of Technology in 2008. He is an associate professor till now in Daiichi Institute of Technology in 2011. His research field is mainly in Civil and Environmental Engineering and Engineering Education.

Yoshimichi Watanabe : received the B.S. and M.S. degrees in computer science from University of Yamanashi, Japan in 1986 and 1988 respectively and received D.S. degree in computer science from Tokyo Institute of Technology, Japan in 1995. He is presently an associate professor of the Department of Computer Science and Engineering at University of Yamanashi. His research interests include software development environment and software quality.

 

 

 

 

 

 

 

Code Clone, Gapped Code Clone, Merging, Refactoring, Maintainability, Readability

Through this paper, we proposed a method for selecting CCs/GCCs for merging by calculating CYCR, COB, and RNR of CCs/GCCs detected by using the SWA. Furthermore, the proposed method also determines a proper merging type from the metrics related to the program structures of those selected CCs/GCCs. We applied the proposed method to the existing programs and confirmed that the proposed method can adequately merge 96% of CCs that were determined to be merged. We also confirmed that the proposed method can properly merge 79% of GCCs that were determined to be merged. The proposed method made it possible to merge CCs/GCCs more efficiently than merging based on exhaustive analysis of all CCs/GCCs. The low percentage of merging GCCs was due to plural gaps existing in GCCs. These GCCs were not merged in this study. This was because we determined that merging such GCCs would be less effective in improving readability and maintainability in comparison with the increasing cost of merging work. The above-mentioned results confirmed that use of the proposed method enabled efficient merging of CCs/GCCs.

 

 

 

 

 

 

 

 

 

[1] Y. Higo, S. Kusmoto and K. Inouse, "A Survey of Code Clone Detection and its Related Techniques", IEICE Transaction on Information and Systems D, Vol. 91-D, No. 6, 2008, pp. 1465-1481. [2] K. M. Bergman, L. L. Lau and D. Notkin, "An Ethnographic Study of Copy and Paste Programming Practices in OOPL, Proceedings 2004 International Symposium on Empirical Software Engineering, 2004, pp. 83-92. [3] L. Bergroth, H. Hakonen and T. Raita, "A Survey of Longest Common Subsequence Algorithms", Proceedings 7th International Symposium on String Processing and Information Retrieval, 2000, pp.39-48. [4] C. K. Roy and J. R. Cordy, "NiCad: Accurate Detection of Near-miss Intentional Clones Using Flexible Pretty printing and Code Normalization", Proceedings 16th International Conference on Program Comprehension, 2008, pp. 172-181. [5] L. Jiang, G. Misherghi, Z. Su and S. Glondu, "DECKARD: Scalable and Accurate Tree-Based Detection of Code Clones", Proceedings the 29th International Conference on Software Engineering, 2007, pp. 96-105. [6] J. Krinke, "Identifying Similar Code with Program Dependence Graphs", Proceedings the 8th Working Conference on Reverse Engineering, 2001, pp. 301-309. [7] S. Temple and W. Michael, "Identification of Common Molecular Subsequences", Journal of Molecular Biology, Vol. 147, 1981, pp. 195–197. [8] H. Murakami, K. Hotta, Y. Higo, H. Igaki and S. Kusumoto, "Gapped Code Clone Detection with Lightweight Source Code Analysis", Proceedings ICPC 2013, 2013, pp. 93-102. [9] H. Murakami, K. Hotta, Y. Higo, H. Igaki and S. Kusumoto, "Gapped Code Clone Detection Using the Smith-Waterman Algorithm" , IPSJ Journal, Vol. 55, No. 2, 2014, pp. 981-993 . [10] Y. Higo and S. Kusumoto, "How Often Do Unintended Inconsistencies Happen? - Deriving Modification Patterns and Detecting Overlooked Code Fragments-", Proceedings 28th IEEE International Conference of Software Maintenance, 2012, pp.222-231. [11] N. Gode and R. Koschke, "Frequency and Risks of Changes to Clones", Proceedings ICSE'11, no page number, 2011, 10pages. [12] N. Fenton and J. Bieman, "Software Metrics -A Rigorous and Practical Approach - Third Edition", CRC press, 2014. [13] K. Hatano, Y. Nomura, H. Taniguti and K. Ushijima, "A Mechanism to Support Automated Refactoring Process Using Software Metrics", IPSJ Journal, Vol.44, No.6, 2003, pp.1548-1557 [14] M. Fowler, K. Beck, J. Brant, W. Opdyke and D. Roberts, "Refactoring: Improving the Design of Existing Code", Addison-Wesley, 1999. [15] Y. Higo, T. Kamiya, S. Kusumoto and K. Inoue, "Refactoring Support Environment Based on Code Clone Analysis", IEICE Transactions D, Vol. J88-DI, No.2, 2005, pp.186-195. [16] T. McCabe, "Complexity Measure", IEEE Transactions on Software Engineering, Vol.2, No 4, 1976, pp 308- 320. [17] M. Ioka, N. Yosida, T. Masai and K. Inoue, "Ranking Candidates for Applying Template Method Pattern with a Cohesion Metric COB", Technical Report of IEICE KBSE, vol.111,No.169, 2011, pp.57-62. [18] Y. Higo, T. Kamiya, S. Kusumoto and K. Inoue, "Method and implementation for investigating code clones in a software system", Information and Software Technology, Vol.49, Issues 9-10, 2007, pp.985-998. [19] R. Yokomori, K. Kondou, F. Ohata and K. Inoue, "Impact Analysis System for Changes on Object- Oriented Programs", IEICE Transactions D, Vol. J86– D–I,No.3, 2003, pp.150–158. [20] M. Takahashi, R. Nanba, Y. Anang and Y. Watanabe, "An Improvement Method for Program Structure Using Code Clone Detection, Impact Analysis, and Refactoring Formats", SICE Journal of Control, Measurement, and System Integration, Vol.10, No.3, 2017, pp. 184-191.