针对已有克隆代码检测工具只输出克隆组形式的检测结果,而难以分析克隆代码对软件质量的影响问题,提出了危害软件质量的关键克隆代码的识别方法。定义了克隆代码的统一表示形式,使之可以分析各种克隆检测工具的检测结果,然后解析源程序和克隆检测结果,识别标志符命名不一致性潜在缺陷,定义了克隆关联图,在此基础上检测跨越多个实现不同功能的文件、危害软件可维护性的克隆代码,最后对检测结果进行可视化统计分析。克隆代码分析工具被应用于分析开源代码httpd,检测出了1组标志符命名不一致的克隆代码和44组危害软件可维护性的关键克隆类。实验结果表明,该方法可以有效辅助软件开发和维护人员分析、维护克隆代码。
Most existing clone detection tools only output the detection results in the form of clone sets,lacking clone analysis.To solve this problem,this paper proposed a key clone recognition approach. The approach could analysis the clones which decreased the quality of software. Firstly,this approach defined a unified clone representation form to support the analysis of various clone detection tools. Then,the approach analysed the source code and clone detection results to detect identifier renaming inconsistent clones,which were potential bugs. Next,the approach detected the clones diffusing in various functional different files,which might decrease the maintainability of software. Finally,the approach visually analysed the detection results. The proposed analysis tool analyzed the open source code httpd,which detected 1 identifier renaming inconsistent clone,and 44 clones diffusing in various functional different files. The experimental results show that it can facilitate the analysis and maintenance of code clones.