Subscribe Now Subscribe Today
Science Alert
Curve Top
Journal of Software Engineering
  Year: 2017 | Volume: 11 | Issue: 3 | Page No.: 266-274
DOI: 10.3923/jse.2017.266.274
Facebook Twitter Digg Reddit Linkedin StumbleUpon E-mail

Detection of Code Clone Based on Source Fragment Alignment

Jie Wang, Dongjin Yu and Xiang Shu

Background: Developers often reuse code segments through copy-paste operation with or without modification during software development which leads to so-called code clone. Code clone brings about some convenience for developers. However, it takes difficulties to the understanding and maintenance of software at the same time. Materials and Methods: A new code clone detection method based on source code alignment is proposed. First, the source code is transformed to token sequences through code preprocessing. Afterwards, the MD5 hash values of each line are calculated in the token sequences. Finally, the candidate code clones are detected based on the calculation of similarity scores of hash sequences. Results: An extensive experiment on 8 open source systems is conducted to measure the precisions and recalls. The results show that the proposed method can detect code clone more effectively than the current methods. Conclusion: The acceleration penalty strategy helps improve the accuracy of code clone detection, because the matched source sequences can be broken into two pairs of more-matched ones if some middle source fragments are not so matched. Additional, following the closed trace-back paths, the proposed method could skip some source fragments, thus further improves its effectiveness.
PDF Fulltext XML References Citation Report Citation
How to cite this article:

Jie Wang, Dongjin Yu and Xiang Shu, 2017. Detection of Code Clone Based on Source Fragment Alignment. Journal of Software Engineering, 11: 266-274.

DOI: 10.3923/jse.2017.266.274






Curve Bottom