Suggesting natural method names to check name consistencies
Son Nguyen, Hung Phan, Trinh Le, Tien N. Nguyen
摘要
Misleading names of the methods in a project or the APIs in a software library confuse developers about program functionality and API usages, leading to API misuses and defects. In this paper, we introduce MNire, a machine learning approach to check the consistency between the name of a given method and its implementation. MNire first generates a candidate name and compares the current name against it. If the two names are sufficiently similar, we consider the method as consistent. To generate the method name, we draw our ideas and intuition from an empirical study on the nature of method names in a large dataset. Our key finding is that high proportions of the tokens of method names can be found in the three contexts of a given method including its body, the interface (the method's parameter types and return type), and the enclosing class' name. Even when such tokens are not there, MNire uses the contexts to predict the tokens due to the high likelihoods of their co-occurrences. Our unique idea is to treat the name generation as an abstract summarization on the tokens collected from the names of the program entities in the three above contexts. We conducted several experiments to evaluate MNire in method name consistency checking and in method name recommending on large datasets with +14M methods. In detecting inconsistency method names, MNire improves the state-of-the-art approach by 10.4% and 11% relatively in recall and precision, respectively. In method name recommendation, MNire improves relatively over the state-of-the-art technique, code2vec, in both recall (18.2% higher) and precision (11.1% higher). To assess MNire's usefulness, we used it to detect inconsistent methods and suggest new names in several active, GitHub projects. We made 50 pull requests (PRs) and received 42 responses. Among them, five PRs were merged into the main branch, and 13 were approved for later merging. In total, in 31/42 cases, the developer teams agree that our suggested names are more meaningful than the current names, showing MNire's usefulness. CCS CONCEPTS • Software and its engineering → Software maintenance tools.
问问这篇 Paper
智能体会读完全文。
Lune 把这篇 Paper 索引到了每一个公式,引用它的顶会 Paper 也一样。你提问,回答直接引用原文。
引用它的顶会 Paper12
- Vulnerability detection with fine-grained interpretationsYi Li, Shaohua Wang, Tien N. NguyenFSE 2021 · 被引用 283 次
- SymLM: Predicting Function Names in Stripped Binaries via Context-Sensitive Execution-Aware Code EmbeddingsXin Jin, Kexin Pei, Jun Yeon Won, Zhiqiang LinCCS 2022 · 被引用 56 次
- Data-driven accessibility repair revisited: on the effectiveness of generating labels for icons in Android appsForough Mehralian, Navid Salehnamadi, Sam MalekFSE 2021 · 被引用 47 次
- Lightweight global and local contexts guided method name recommendation with prior knowledgeShangwen Wang, Ming Wen, Bo Lin, Xiaoguang MaoFSE 2021 · 被引用 38 次
- A Context-based Automated Approach for Method Name Consistency Checking and SuggestionYi Li, Shaohua Wang, Tien N. NguyenICSE 2021 · 被引用 36 次
相关 Paper
- Learning to Recommend Method Names with Global ContextFang Liu, Ge Li, Zhiyi Fu, Shuai Lu 等ICSE 2022 · 被引用 32 次
- LLM-Based Method Name Suggestion with Automatically Generated Context-Rich PromptsWaseem Akram, Yanjie Jiang, Yuxia Zhang, Haris Ali Khan 等FSE 2025 · 被引用 1 次
- Learning to find naming issues with big code and small supervisionJingxuan He, Cheng-Chun Lee, Veselin Raychev, Martin T. VechevPLDI 2021 · 被引用 9 次
- Nalin: learning from Runtime Behavior to Find Name-Value Inconsistencies in Jupyter NotebooksJibesh Patra, Michael PradelICSE 2022 · 被引用 14 次
- OCoR: An Overlapping-Aware Code RetrieverQihao Zhu, Zeyu Sun, Xiran Liang, Yingfei Xiong 等ASE 2020 · 被引用 28 次
