软件开发中,因代码复用导致复用缺陷的现象时常发生,针对此提出一种基于代码复用检测的缺陷发现方法。首先通过代码比对或补丁还原的方式定位缺陷相关的代码,将缺陷代码和待测代码以函数为单位进行划分,提取并量化各函数的度量特征、结构特征和文本特征,采用递进式相似函数逐轮筛选的方式,确定可能存在复用缺陷的函数,并基于模型检测和数据流分析技术对疑似缺陷进一步判断。实验选取典型开源项目进行测试,发现了多处潜在的复用缺陷,结果证明了所提方法的有效性,同时发现每个缺陷平均要对2~5个可能的复用点进行判断。
In software development,clone flaw phenomena caused by code clone occur at intervals.A method based on code clone detection was proposed to detect the clone flaws.The code area related to the flaw was located by code comparison or patch restoration.The flaw code and testing code were divided into functions as the analysis unit.By selecting and quantifying the metric feature,structure feature and text feature for every function,functions those may have clone flaws were identified using the progressive similar function filtration way.These suspected flaws were ensured using model checking and data-flow analysis.In the experiment with several typical open source projects,a number of clone flaws were detected.The results validate the effectiveness of the proposed method.Furthermore,a conclusion was drawn that when finding a flaw,averaging 2-5clone points should be checked.