Design and Development of an Efficient Software Clone Detection Technique

syntax trees and parse trees are frequently used representations when source code is to be transformed into tree structures. However, tools based on this approach suffer from large execution times when analysing a large source code base. The output is purely syntactic units of source code which are ready for refactoring. Tree based clone detection is capable of detecting clones in which the code is inserted or deleted i.e. type-3 clones. Yang [241] proposed one of the first approaches for finding the syntactic differences between two versions of the same program. The technique was based on grammar and builds a variant of a parse tree for both the versions. Detection is applied synchronously to both the trees and is based on the longest common subsequence method of dynamic programming. A limitation of this approach is that his differential comparator can only work for syntactically correct programs conforming to the grammar. Semantic Designs' CloneDR [23] is another tool which is able to detect exact and near miss clones using hashing and dynamic programming. The tool has different variants for different programming languages. The study reported the use of clone detection in finding commonalities in the form of domain concepts in source code which will help analysts in understanding the design of the system for better maintenance. SimScan [211] and ccdiml [20] are variations of CloneDR. ccdiml transforms the source to intermediate representation and SimScan applies subtree comparison on the parsed source code. The source code is parsed with the help of ANTLR parser generator. SimScan and ccdiml have been used to classify the evolution of source code clone fragments in Java and C source code files [227]. Falke et al. [55] and Tairas and Gray [220] used suffix tree to detect clones in code transformed into an AST. The technique has advantage of precision of syntax tree and high speed of suffix tree. 30 Gitchell and Tran [63] developed Sim which converts source programs to parse trees. Viewing parse trees as strings, the tool applied longest common subsequence and dynamic programming to assess similarity. Deckard by Jiang et al. [95] is based on computing characteristic vectors from the AST and clustering vectors which are close in Euclidean space by locality sensitive hashing. Deckard has been used in localizing the representation of clone groups [224] and has been used to detect behaviorally similar code [104]. Another application of Deckard is to assess the impact of code clone on defects in source code [189]. Asta [54] is an AST based tool which works on the phenomenon of structural abstraction of arbitrary sub trees of an AST. ClemanX [180,181] is an incremental AST based framework. The tool constructs characteristic vectors from AST subtrees and used locality sensitive hashing. Saebjornsen et al. [200] also used the same set of techniques to detect clones in assembly code. Anti-unification is used in three studies [29,31,151] to calculate the distance between two AST‟s and grouping the similar classes in one cluster. Anti-unification helps to discover common sub-expressions in source code represented as a tree. CloneDigger [31] is a language independent tool in which anti-unification is applied to XML representation of source code. CloneDetection, a tree based tool by Wahler et al. [233], is based on frequent itemset mining applied on XML representation of source code. Chilowicz et al. [355] developed a new technique to detect exact clones based on syntax tree fingerprinting. Shifting our focus to code clone management, CSeR (Code Segment Reuse) was developed by Jacob et al. [89] to check copy and paste induced clones in an integrated development environment. The tool was designed to compute clone differences interactively by checking if some piece of code was copy-pasted as the programmer was editing and typing the code. It works on the phenomenon of converting the immediate clone to an AST and computing the difference with the original in a bi-directional manner using metrics like the Levenshtein distance. Biegel and Diehl [26] introduced a novel way for fast and configurable code clone detection using pipelines. They developed JCCD, a flexible and customisable AST based clone detection tool in which several cascaded processors perform various steps of clone detection process. JCCD API parallelizes the detection process using multiple cores.