Just-In-Time obsolete comment detection and update

Comments are valuable resources for the development, comprehension and maintenance of software. However, while changing code, developers sometimes neglect the evolution of the corresponding comments, resulting in obsolete comments. Such obsolete comments can mislead developers and introduce bugs in...

Full description

Saved in:
Bibliographic Details
Main Authors: LIU, Zhongxin, XIA, Xin, LO, David, YAN, Meng, LI, Shangping
Format: text
Language:English
Published: Institutional Knowledge at Singapore Management University 2023
Subjects:
Online Access:https://ink.library.smu.edu.sg/sis_research/7769
https://ink.library.smu.edu.sg/context/sis_research/article/8772/viewcontent/tse221_JIT_ObsoleteComment_av.pdf
Tags: Add Tag
No Tags, Be the first to tag this record!
Institution: Singapore Management University
Language: English
Description
Summary:Comments are valuable resources for the development, comprehension and maintenance of software. However, while changing code, developers sometimes neglect the evolution of the corresponding comments, resulting in obsolete comments. Such obsolete comments can mislead developers and introduce bugs in the future, and are therefore detrimental. We notice that by detecting and updating obsolete comments in time with code changes, obsolete comments can be effectively reduced and even avoided. We refer to this task as Just-In-Time (JIT) Obsolete Comment Detection and Update. In this work, we propose a two-stage framework named CUP2 (Two-stage Comment UPdater) to automate this task. CUP2 consists two components, i.e., an Obsolete Comment Detector named OCD and a Comment UPdater named CUP, each of which relies on a distinct neural network model to perform detection (updates). Specifically, given a code change and a corresponding comment, CUP2 first leverages OCD to predict whether this comment should be updated. If the answer is yes, CUP will be used to generate the new version of the comment automatically. To evaluate CUP2 , we build a large-scale dataset with over 4 million code-comment change samples. Our dataset focuses on method-level code changes and updates on method header comments considering the importance and widespread use of such comments. Evaluation results show that 1) both OCD and CUP outperform their baselines by significant margins, and 2) CUP2 performs better than a rule-based baseline. Specifically, the comments generated by CUP2 are identical to the ground truth for 41.8% of the samples that are predicted to be positive by OCD. We believe CUP2 can help developers detect obsolete comments, better understand where and how to update obsolete comments and reduce their edits on obsolete comment updates.