Automating the removal of obsolete TODO comments

TODO comments are very widely used by software developers to describe their pending tasks during software development. However, after performing the task developers sometimes neglect or simply forget to remove the TODO comment, resulting in obsolete TODO comments. These obsolete TODO comments can confuse development teams and may cause the introduction of bugs in the future, decreasing the software's quality and maintainability. Manually identifying obsolete TODO comments is time-consuming and expensive. It is thus necessary to detect obsolete TODO comments and remove them automatically before they cause any unwanted side effects. In this work, we propose a novel model, named TDCleaner, to identify obsolete TODO comments in software projects. TDCleaner can assist developers in just-in-time checking of TODO comments status and avoid leaving obsolete TODO comments. Our approach has two main stages: offline learning and online prediction. During offline learning, we first automatically establish training samples and leverage three neural encoders to capture the semantic features of TODO comment, code change and commit message respectively. TDCleaner then automatically learns the correlations and interactions between different encoders to estimate the final status of the TODO comment. For online prediction, we check a TODO comment's status by leveraging the offline trained model to judge the TODO comment's likelihood of being obsolete. We built our dataset by collecting TODO comments from the top-10,000 Python and Java Github repositories and evaluated TDCleaner on them. Extensive experimental results show the promising performance of our model over a set of benchmarks. We also performed an in-the-wild evaluation with real-world software projects, we reported 18 obsolete TODO comments identified by TDCleaner to Github developers and 9 of them have already been confirmed and removed by the developers, demonstrating the practical usage of our approach.

[1]  David Lo,et al.  Automating Change-Level Self-Admitted Technical Debt Determination , 2019, IEEE Transactions on Software Engineering.

[2]  Yuanyuan Zhou,et al.  /*icomment: bugs or bad comments?*/ , 2007, SOSP.

[3]  David Lo,et al.  SmartEmbed: A Tool for Clone and Bug Detection in Smart Contracts through Structural Code Embedding , 2019, 2019 IEEE International Conference on Software Maintenance and Evolution (ICSME).

[4]  Omer Levy,et al.  BART: Denoising Sequence-to-Sequence Pre-training for Natural Language Generation, Translation, and Comprehension , 2019, ACL.

[5]  Lukasz Kaiser,et al.  Attention is All you Need , 2017, NIPS.

[6]  Gary T. Leavens,et al.  @tComment: Testing Javadoc Comments to Detect Comment-Code Inconsistencies , 2012, 2012 IEEE Fifth International Conference on Software Testing, Verification and Validation.

[7]  David Lo,et al.  Identifying self-admitted technical debt in open source projects using text mining , 2017, Empirical Software Engineering.

[8]  Emad Shihab,et al.  An Exploratory Study on Self-Admitted Technical Debt , 2014, 2014 IEEE International Conference on Software Maintenance and Evolution.

[9]  Tat-Seng Chua,et al.  Neural Collaborative Filtering , 2017, WWW.

[10]  David Lo,et al.  Deep Code Comment Generation , 2018, 2018 IEEE/ACM 26th International Conference on Program Comprehension (ICPC).

[11]  Ahmed E. Hassan,et al.  Understanding the rationale for updating a function’s comment , 2008, 2008 IEEE International Conference on Software Maintenance.

[12]  Yuanyuan Zhou,et al.  aComment: mining annotations from comments and code to detect interrupt related concurrency bugs , 2011, 2011 33rd International Conference on Software Engineering (ICSE).

[13]  Xiaodong Gu,et al.  Deep Code Search , 2018, 2018 IEEE/ACM 40th International Conference on Software Engineering (ICSE).

[14]  Ming-Wei Chang,et al.  BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding , 2019, NAACL.

[15]  Martin P. Robillard,et al.  Detecting fragile comments , 2017, 2017 32nd IEEE/ACM International Conference on Automated Software Engineering (ASE).

[16]  Ding Yuan,et al.  HotComments: How to Make Program Comments More Useful? , 2007, HotOS.

[17]  Ting Zhang,et al.  Sentiment Analysis for Software Engineering: How Far Can Pre-trained Transformer Models Go? , 2020, 2020 IEEE International Conference on Software Maintenance and Evolution (ICSME).

[18]  Gabriele Bavota,et al.  A Large-Scale Empirical Study on Code-Comment Inconsistencies , 2019, 2019 IEEE/ACM 27th International Conference on Program Comprehension (ICPC).

[19]  Christoph Treude,et al.  Wait for it: identifying “On-Hold” self-admitted technical debt , 2020, Empirical Software Engineering.

[20]  Janice Singer,et al.  TODO or to bug , 2008, 2008 ACM/IEEE 30th International Conference on Software Engineering.

[21]  David Lo,et al.  Technical Q8A Site Answer Recommendation via Question Boosting , 2020, ACM Trans. Softw. Eng. Methodol..

[22]  Nicolas Anquetil,et al.  A study of the documentation essential to software maintenance , 2005, SIGDOC '05.

[23]  Zhendong Su,et al.  Detecting API documentation errors , 2013, OOPSLA.

[24]  Meng Yan,et al.  Automating Just-In-Time Comment Updating , 2020, 2020 35th IEEE/ACM International Conference on Automated Software Engineering (ASE).

[25]  Zhenchang Xing,et al.  Neural Network-based Detection of Self-Admitted Technical Debt: From Performance to Explainability , 2019, ACM Trans. Softw. Eng. Methodol..

[26]  James L. Wright,et al.  Source code that talks: an exploration of Eclipse task comments and their implication to repository mining , 2005, MSR '05.

[27]  Xiaodong Gu,et al.  Deep API learning , 2016, SIGSOFT FSE.

[28]  David Lorge Parnas,et al.  Precise Documentation: The Key to Better Software , 2010, The Future of Software Engineering.

[29]  Junyi Jessy Li,et al.  Learning to Update Natural Language Comments Based on Code Changes , 2020, ACL.

[30]  Sarfraz Khurshid,et al.  A framework for writing trigger-action todo comments in executable format , 2019, ESEC/SIGSOFT FSE.

[31]  Gabriele Bavota,et al.  Automated Identification of On-hold Self-admitted Technical Debt , 2020, 2020 IEEE 20th International Working Conference on Source Code Analysis and Manipulation (SCAM).

[32]  Giriprasad Sridhara Automatically Detecting the Up-To-Date Status of ToDo Comments in Java Programs , 2016, ISEC.

[33]  Collin McMillan,et al.  Automatically generating commit messages from diffs using neural machine translation , 2017, 2017 32nd IEEE/ACM International Conference on Automated Software Engineering (ASE).

[34]  J. Grundy,et al.  Generating Question Titles for Stack Overflow from Mined Code Snippets , 2020, ACM Trans. Softw. Eng. Methodol..

[35]  Xiaonan Luo,et al.  Automatic Detection of Outdated Comments During Code Changes , 2018, 2018 IEEE 42nd Annual Computer Software and Applications Conference (COMPSAC).

[36]  Jimmy Ba,et al.  Adam: A Method for Stochastic Optimization , 2014, ICLR.

[37]  Nitish Srivastava,et al.  Dropout: a simple way to prevent neural networks from overfitting , 2014, J. Mach. Learn. Res..

[38]  Lingxiao Jiang,et al.  Checking Smart Contracts With Structural Code Embedding , 2020, IEEE Transactions on Software Engineering.

[39]  Ahmed E. Hassan,et al.  On the relationship between comment update practices and Software Bugs , 2012, J. Syst. Softw..

[40]  Iz Beltagy,et al.  SciBERT: A Pretrained Language Model for Scientific Text , 2019, EMNLP.