一句话:提出 CPC,用程序分析系统化推导、精炼并传播代码注释,辅助缺陷检测。
代码注释有助于缺陷检测、规约推断和代码合成,但开发者常不愿编写和更新注释,直接利用注释不可行且易错。本文提出用程序分析系统化地推导、精炼和传播注释,并建立细粒度注释分类体系与自动分类器。作者实现原型 CPC,在 5 个项目上评估:以 88% 准确率从其他代码位置传播得到 41573 条新注释,为 87 个无注释且无源码的 native 方法生成功能注释;据此发现开源大型项目中 37 个新缺陷(30 个被确认修复),以及现有注释中 304 个缺陷(12 条不完整、292 条错误)。用户研究显示传播注释质量与已有注释相当。
Code comments provide abundant information that have been leveraged to help perform various software engineering tasks, such as bug detection, specification inference, and code synthesis. However, developers are less motivated to write and update comments, making it infeasible and error-prone to leverage comments to facilitate software engineering tasks. In this paper, we propose to leverage program analysis to systematically derive, refine, and propagate comments. For example, by propagation via program analysis, comments can be passed on to code entities that are not commented such that code bugs can be detected leveraging the propagated comments. Developers usually comment on different aspects of code elements like methods, and use comments to describe various contents, such as functionalities and properties. To more effectively utilize comments, a fine-grained and elaborated taxonomy of comments and a reliable classifier to automatically categorize a comment are needed. In this paper, we build a comprehensive taxonomy and propose using program analysis to propagate comments. We develop a prototype CPC, and evaluate it on 5 projects. The evaluation results demonstrate 41573 new comments can be derived by propagation from other code locations with 88% accuracy. Among them, we can derive precise functional comments for 87 native methods that have neither existing comments nor source code. Leveraging the propagated comments, we detect 37 new bugs in open source large projects, 30 of which have been confirmed and fixed by developers, and 304 defects in existing comments (by looking at inconsistencies between existing and propagated comments), including 12 incomplete comments and 292 wrong comments. This demonstrates the effectiveness of our approach. Our user study confirms propagated comments align well with existing comments in terms of quality.
DOI 原文 ·
@inproceedings{paperbot5578,
title = {CPC},
author = {Juan Zhai and Xiangzhe Xu and Yu Shi and Guanhong Tao and Minxue Pan and Shiqing Ma and Lei Xu and Weifeng Zhang and Lin Tan and Xiangyu Zhang},
booktitle = {ICSE},
year = {2020},
doi = {10.1145/3377811.3380427}
}