Font Size: a A A

The Amorphous Clone Code Detection And Reconstruction System Design And Implementation

Posted on:2015-04-11Degree:MasterType:Thesis
Country:ChinaCandidate:C DongFull Text:PDF
GTID:2348330422491916Subject:Computer technology
Abstract/Summary:PDF Full Text Request
Cloning code widely exists in the software system, and it can reduce the qualityand maintainability of the software system, detecting and refactoring clone code of thesoftware system is very important to improve the quality of the software system.Existing detection tools are generally only for one type of code clone detection orreconstruct, for solve this problem, this paper realizes the multiple types of code clonedetection and reconstruction.This paper completed the following tasks:In syntax similar code clone detection, we use CPFinder to achieve syntax similarcode clone detection, Since CPFinder does not provide external interface, cannot beintegrated directly into the system, this paper manual analysis CPFinder source code,extracting the source of detection and packaging it into dynamic link library, after whichthe system calls the dynamic link library to achieve the similar syntax clone codedetection.In functionally equivalent clone code detection, first, for the output parameter ofcode fragment generated by K-nearest neighbor clustering algorithm is called by value,the paper preprocess the output parameters of the call by value and convert it to call byaddress. Secondly, the System uses static analysis to divide the code fragments. Again,the design of the new test data generation algorithm, to reduce the number of test set.Finally, Optimizing the dynamic test algorithms to reduce the number of concurrentprocesses, and improve the detection efficiency.In the functional equivalent clone code refactoring, the paper first implements a thestatic feature preferred algorithm. Secondly, the runtime preferred algorithm andparameter matching algorithm time efficiency is not high, This paper optimized theruntime preferred algorithm, dynamic test step can be omitted, thus improving timeefficiency. The system optimizes parameters matching algorithm, capable of eliminatingthe step of static analysis and dynamic testing, improving the accuracy of matching timeefficiency under the same circumstances.In the structurally semantic similar clone code detection, First, since code snippetsgenerated by the sliding window algorithm based on the program source is incompletegrammar, we designed and implemented a sliding window algorithm based on syntaxtree can produce the complete syntax candidate code. Secondly, this paper adds somenew standardized rules and optimizes the form of weights on the standardized module,so the order of the relationship between variables can be represented. Then, this articleachieves the standardization and variable rename operation in the syntax tree. Finally, the calculation method is designed and implemented between the code fragments, Theresults calculated is used to obtain the structurally semantic similar clone code.In refactor of structurally semantic similar clone code, First, Due to the use ofCPFinder find points of difference exist mistakenly identified, and the whole process offind the points of differences need to manual operation, this paper designed andimplemented edit distance algorithm to find points of difference. Secondly, the paperadded some refactoring judgments. Finally, considering the case of the reconstructionalgorithm only points of difference corresponding to each other, the paper added twonew relations of the two points in code snippet which is no correspondence andimproved the reconstruction algorithm.In this paper, the functional equivalent clone code clone code detection is tested bystudent program, the structurally semantic similar clone code detection is tested in thestudents program and open source code project. Experiments show that functionallyequivalent code clone detection realized by this paper has high time efficiency andaccuracy, structurally semantic similar clone code detection has lower false detectionrate and false negative rate.
Keywords/Search Tags:clone code, clone detection, software refactoring, static analysis, dynamictesting
PDF Full Text Request
Related items