作者投稿和查稿 主编审稿 专家审稿 编委审稿 远程编辑

计算机工程 ›› 2020, Vol. 46 ›› Issue (10): 216-222,230. doi: 10.19678/j.issn.1000-3428.0055862

• 体系结构与软件技术 • 上一篇    下一篇

基于BP神经网络的代码坏味检测

王曙燕, 张一权, 孙家泽   

  1. 西安邮电大学 计算机学院, 西安 710000
  • 收稿日期:2019-08-30 修回日期:2019-11-06 发布日期:2019-11-22
  • 作者简介:王曙燕(1964-),女,教授、博士,主研方向为软件测试、数据挖掘、智能信息处理;张一权(通信作者),硕士研究生;孙家泽,教授、博士。
  • 基金资助:
    陕西省科技厅工业公关项目"基于搜索的程序并行测试数据优化关键技术"(2018GY-014);西安市科技计划项目"基于群体智能的多目标软件测试优化关键技术研究"(GXYD17.10)。

Detection of Bad Smell in Code Based on BP Neural Network

WANG Shuyan, ZHANG Yiquan, SUN Jiaze   

  1. School of Computer Science and Technology, Xi'an University of Posts and Telecommunications, Xi'an 710000, China
  • Received:2019-08-30 Revised:2019-11-06 Published:2019-11-22

摘要: 程序中若出现代码坏味将严重影响其质量且难以对软件维护提供保障。针对机器学习算法在代码坏味检测中准确度较低以及数据集仅存在单一类型代码坏味的问题,提出一种基于BP神经网络的代码坏味检测方法。考虑软件实际开发过程中会存在不同类型的坏味,对数据类、上帝类、长方法和特征依恋4种代码坏味进行研究并将其合并为方法级别和类级别的2种坏味数据集,根据数据集中的标签信息进行有监督深度学习,进而构建代码坏味的真假阳性检测模型。实验结果表明,相比基于机器学习和基于度量的代码坏味检测方法,该方法的平均准确度提高15.19%,平均F1值提高58.39%。

关键词: 代码坏味, 软件维护, BP神经网络, 深度学习, 检测模型

Abstract: Bad smells in code seriously affect the quality of software and its maintenance.To address the low accuracy of machine learning algorithms in bad smell detection and the single type of bad smell dataset,this paper proposes a detection method for bad smells in code based on BP Neural Network(BPNN).Considering that there are different types of bad smells in the actual development of software,four types of bad smells,Data class,God class,Long method,and Feature envy,are studied and merged into method-level and class-level code smell datasets.Based on the label information in the dataset,supervised deep learning is implemented to build a true and false positive prediction model for bad smells.The experimental results show that compared with the bad smell detection methods based on machine learning and metric,the proposed method improves the average accuracy by 15.19% and the average F1 value by 58.39%.

Key words: bad smell in code, software maintenance, BP Neural Network(BPNN), deep learning, detection model

中图分类号: