一句话:提出注释分类与传播方法,利用NLP和语言语义规则在代码实体间传播注释,以检测代码bug和注释缺陷。
自然语言注释是连接人类逻辑与软件语义的桥梁,但代码中常存在注释缺失、错误或不一致。本文对注释进行分类,利用自然语言处理技术提取注释信息,并基于编程语言语义为每类注释构建规则,在代码实体间系统地传播注释。随后用传播得到的注释检查代码使用方式与注释一致性。在真实项目中的原型系统发现37个代码错误,其中30个已被开发者确认;还发现304条缺陷注释,包括12条误导性注释和292条不正确注释。在传播的41573条注释中,87条针对既无代码也无注释的私有native方法。用户研究表明,传播注释在一致性、自然性和意义性三个维度上与人工注释相当。
Natural language comments are like bridges between human logic and software semantics. Developers use comments to describe the function, implementation, and property of code snippets. This kind of connections contains rich information, like the potential types of a variable and the pre-condition of a method, among other things. In this paper, we categorize comments and use natural language processing techniques to extract information from them. Based on the semantics of programming languages, different rules are built for each comment category to systematically propagate comments among code entities. Then we use the propagated comments to check the code usage and comments consistency. Our demo system finds 37 bugs in real-world projects, 30 of which have been confirmed by the developers. Except for bugs in the code, we also find 304 pieces of defected comments. The 12 of them are misleading and 292 of them are not correct. Moreover, among the 41573 pieces of comments we propagate, 87 comments are for private native methods which had neither code nor comments. We also conduct a user study where we find that propagated comments are as good as human-written comments in three dimensions of consistency, naturalness, and meaningfulness.
DOI 原文 ·
@inproceedings{paperbot5956,
title = {The classification and propagation of program comments},
author = {Xiangzhe Xu},
booktitle = {ASE},
year = {2020},
doi = {10.1145/3324884.3418913}
}