{"title":"HatCUP: Hybrid Analysis and Attention based Just-In-Time Comment Updating","authors":"Hongquan Zhu, Xincheng He, Lei Xu","doi":"10.1145/3524610.3527901","DOIUrl":null,"url":null,"abstract":"When changing code, developers sometimes neglect updating the related comments, bringing inconsistent or outdated comments. These comments increase the cost of program understanding and greatly reduce software maintainability. Researchers have put forward some solutions, such as CUP and HEBCUP, which update comments efficiently for simple code changes (i.e. modifying of a single token), but not good enough for complex ones. In this paper, we propose an approach named HatCUP (Hybrid Analysis and Attention based Comment UPdater), to provide a new mechanism for comment updating task. HatCUP pays attention to hybrid analysis and information. First, HatCUP considers the code structure change information and introduces a structureguided attention mechanism combined with code change graph analysis and optimistic data flow dependency analysis. With a generally popular RNN-based encoder-decoder architecture, HatCUP takes the action of the code edits, the syntax, semantics and structure code changes, and old comments as inputs and generates a structural representation of the changes in the current code snippet. Furthermore, instead of directly generating new comments, HatCUP proposes a new edit or nonedit mechanism to mimic human editing behavior, by generating a sequence of edit actions and constructing a modified RNN model to integrate newly developed components. Evaluation on a popular dataset demonstrates that HatCUP outper-forms the state-of-the-art deep learning-based approaches (CUP) by 53.8% for accuracy, 31.3% for recall and 14.3% for METEOR of the original metrics. Compared with the heuristic-based approach (HEBCUP), HatCUP also shows better overall performance.","PeriodicalId":426634,"journal":{"name":"2022 IEEE/ACM 30th International Conference on Program Comprehension (ICPC)","volume":"102 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"2022-05-01","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"2","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"2022 IEEE/ACM 30th International Conference on Program Comprehension (ICPC)","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.1145/3524610.3527901","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 2
Abstract
When changing code, developers sometimes neglect updating the related comments, bringing inconsistent or outdated comments. These comments increase the cost of program understanding and greatly reduce software maintainability. Researchers have put forward some solutions, such as CUP and HEBCUP, which update comments efficiently for simple code changes (i.e. modifying of a single token), but not good enough for complex ones. In this paper, we propose an approach named HatCUP (Hybrid Analysis and Attention based Comment UPdater), to provide a new mechanism for comment updating task. HatCUP pays attention to hybrid analysis and information. First, HatCUP considers the code structure change information and introduces a structureguided attention mechanism combined with code change graph analysis and optimistic data flow dependency analysis. With a generally popular RNN-based encoder-decoder architecture, HatCUP takes the action of the code edits, the syntax, semantics and structure code changes, and old comments as inputs and generates a structural representation of the changes in the current code snippet. Furthermore, instead of directly generating new comments, HatCUP proposes a new edit or nonedit mechanism to mimic human editing behavior, by generating a sequence of edit actions and constructing a modified RNN model to integrate newly developed components. Evaluation on a popular dataset demonstrates that HatCUP outper-forms the state-of-the-art deep learning-based approaches (CUP) by 53.8% for accuracy, 31.3% for recall and 14.3% for METEOR of the original metrics. Compared with the heuristic-based approach (HEBCUP), HatCUP also shows better overall performance.
当更改代码时,开发人员有时会忽略更新相关的注释,从而带来不一致或过时的注释。这些注释增加了理解程序的成本,并大大降低了软件的可维护性。研究人员提出了一些解决方案,如CUP和HEBCUP,对于简单的代码更改(即修改单个令牌),它们可以有效地更新注释,但对于复杂的代码更改则不够好。本文提出了一种名为HatCUP (Hybrid Analysis and Attention based Comment UPdater)的方法,为评论更新任务提供了一种新的机制。HatCUP注重混合分析和信息。首先,HatCUP考虑了代码结构变化信息,引入了结合代码变化图分析和乐观数据流依赖分析的结构导向关注机制。使用普遍流行的基于rnn的编码器-解码器架构,HatCUP将代码编辑、语法、语义和结构代码更改以及旧注释作为输入,并在当前代码片段中生成更改的结构化表示。此外,HatCUP并没有直接生成新的评论,而是提出了一种新的编辑或非编辑机制来模拟人类的编辑行为,方法是生成一系列编辑动作,并构建一个改进的RNN模型来集成新开发的组件。对一个流行数据集的评估表明,HatCUP在原始指标的准确性、召回率和流星率方面比最先进的基于深度学习的方法(CUP)高出53.8%、31.3%和14.3%。与基于启发式的方法(HEBCUP)相比,HatCUP也表现出更好的综合性能。