摘要
代码味道的识别与自动重构是近年来软件工程的热点领域之一,而重复代码是一种在软件工程中较为常见的代码味道。本文在基于文本的重复代码识别方法的基础上,通过词法分析对特定的Token作出处理后再对源代码进行对比,最后通过语法树的对比来对结果进行过滤以降低误报率。测试结果表明该方法对于重复代码有着较好的识别效果。对重复代码的自动识别算法研究有着借鉴意义,在软件的质量、维护等领域上也具有广泛的应用需求。
In the recent years, detection and automatic refactoring of code smell is one of the focus topic in software engineering, and duplicated code is a kind of common code smell. Based on the duplicated code recogni-tion method of text, the false positives can be reduced through the lexical analysis to compare the source code after handling the specific token and through the comparison with the abstract syntax tree to filter the results. The test re-sults show that the method has better detection effect of duplicated code. This has great significance in the study of automatic detection algorithm of duplicated code, and there is also wild application in software maintenance and software quality.
作者
刘伟
宾航飞
胡志刚
LIU Wei;BIN Hang-fei;HU Zhi-gang(School of Informatics,Hunan University of Chinese Medicine,Changsha 410208,Hunan,China;School of Software,Central South University,Changsha 410075,Hunan,China)
出处
《软件》
2018年第10期68-73,共6页
Software
关键词
重复代码
代码味道
自动识别
抽象语法树
Duplicated code
Code smell
Automatic detection
Abstract syntax tree