Logo image
CPC: automatically classifying and propagating natural language comments via program analysis
Accepted manuscript   Open access   Peer reviewed

CPC: automatically classifying and propagating natural language comments via program analysis

Juan Zhai, Xiangzhe Xu, Yu Shi, Guanhong Tao, Minxue Pan, Shiqing Ma, Lei Xu, Weifeng Zhang, Lin Tan and Xiangyu Zhang
42nd International Conference on Software Engineering (ICSE '20)
2020
DOI:
https://doi.org/10.7282/t3-nsjs-4386

Abstract

Code comments provide abundant information that have been lever-aged 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.
pdf
camera475.72 kBDownloadView
Accepted Manuscript Open Access
url
https://doi.org/10.1145/3377811.3380427View
42nd International Conference on Software Engineering (ICSE '20)
url
Report an accessibility issueView
Please complete a content remediation request to report an accessibility issue with a library electronic resource, website, or service.

Metrics

935 File downloads
656 Record Views

Details

Logo image