摘要
为了实现代码缺陷与代码味道的自动探测与优化,提升优化与重构的效率,设计并开发了一套名为SCORT的源代码优化与重构工具。SCORT将源代码解析为抽象语法树,再探测其中存在的代码缺陷和代码味道,最后对缺陷和味道进行自动优化和重构。在SCORT中已经实现了对15种常见代码缺陷和六种常见代码味道的检测以及自动优化与重构,提供了多种代码味道的自动重构算法,且具有良好的可扩展性。通过对三个待测项目的探测和优化实验结果表明,对于常见代码缺陷的探测和优化,SCORT的精确率、召回率和准确率均可达100%;对于部分常见的代码味道,SCORT尚需进一步完善。SCORT有助于开发人员提高代码质量,减少源代码中存在的缺陷和味道。
To implement automated detection and optimization of code defects and code smells, and to improve the efficiency of code optimization and refactoring, this paper designed and developed a source code optimization and refactoring tool called SCORT. Firstly, SCORT parsed source code to an abstract syntax tree (AST), then detected the code defects and code smells in AST, finally, executed automated optimization and refactoring for existing defects and smells. SCORT could detect and optimize 15 kinds of common code defects and 6 kinds of common code smells. And it provided several code smells refactoring algorithms and had good scalability. Through detection and optimization experiments for three projects, the results show that for common code defects' detection and optimization, the precision, recall and accuracy can achieve 100% in SCORT, but for some common code smells, SCORT needs to be improved further. SCORT can help developers to improve code quality, and reduce defects and bad smells in source code.
出处
《计算机应用研究》
CSCD
北大核心
2014年第1期170-176,共7页
Application Research of Computers
基金
国家自然科学基金资助项目(60970038
61272148)
湖南省研究生科研创新基金资助项目(CX2012B068)
关键词
代码缺陷
代码味道
探测
优化
重构
抽象语法树
code defects code smells detection optimization refactoring abstract syntax tree