Font Size: a A A

Research On Refactoring Of Code Clone By Combining Static Analysis With Dynamic Testing

Posted on:2014-09-28Degree:MasterType:Thesis
Country:ChinaCandidate:X LiFull Text:PDF
GTID:2268330422950626Subject:Computer Science and Technology
Abstract/Summary:PDF Full Text Request
Detection and Refactoring of code clone is an important way to improve thereliability and quality of software. So far, as the two types of code clone, functionallyequivalent code clone and structural semantic similar code clone are more complicatedthan syntactically similar clone code, so the detection and refactoring of the two types isless. The method of detecting functionally equivalent code clone has the problem ofhigh time complexity. And there is no related work of refactoring functionallyequivalent code clone and structural semantic similar code clone.In response to these problems, this paper mainly completed the following work.Above all, aiming at the shortcomings of the current research of detecting functionallyequivalent code clone, this paper proposes a functionally equivalent clone candidatecode extraction method based on static analysis. First of all, the parameter informationis extracted from the highly cohesive and functionally independent code fragmentswhich produced by the K-nearest neighbor clustering algorithm. Then the initial codeclone sets are filtered and classified step by step to get the clone candidate code groupsaccording to the number and type of parameters. The candidate code groups are theinput of dynamic testing of functionally equivalent code clone detection. In the nextplace, for the refactoring of functionally equivalent code clone, this paper put forwardtwo kinds of optimization criteria. Then the optimized function is determined by theoptimization criteria. Next, the corresponding relation of parameters between theoptimized function and the non-optimized function is determined. The refactoringprogram is gotten by the process replacement. At last, on the question of refactoringstructural semantic similar code clone, this paper proposes the standardization rules, andthe program is transformed into the standard format. Then the different code clone isachieved by the detection tool and the different code clone is analyzed to get thedifference. The difference data is compared with the metric to determine whether itshould be refactored. Finally, the result of program difference merging is shown if theprogram is suitable for refactoring, otherwise the advice of not suitable for refactoring isgiven out.This paper uses the C small program submitted by the student and the open sourcecode as the test data. The experiment of functionally equivalent clone candidate codeextraction method based on static analysis showed that the proposed method in thispaper can get the candidate code clone with a lower time complexity. The experiment offunctionally equivalent code clone refactoring, structural semantic similar code clonerefactoring and the manual verification proved that the method can refactor program currently.
Keywords/Search Tags:clone detection, clone refactoring, static analysis, dynamic testing
PDF Full Text Request
Related items