一句话:提出基于方法名与代码一致性的深度特征方法,自动检测不一致方法名并建议重命名,显著优于现有方法。
方法名必须与实现保持一致,才能保证代码可读性与可维护性。现有方法名调试技术主要分析大规模数据中名称的共现模式,而未分析方法实现代码本身来评估一致性。本文提出一种自动化方法名调试方法,针对方法名和方法代码各自的特点,采用深度特征表示技术,分析名称与代码之间的一致性。在超过210万个Java方法上的实验表明,该方法在识别不一致方法名上达到67.9%的F1值,比当前最优方法提升最多15个百分点;在建议完整方法名方面准确率最高达25%,而当前最优方法仅为1.1%。最后,在真实项目开展的实地研究中,该方法成功修复了66个不一致方法名。
To ensure code readability and facilitate software maintenance, program methods must be named properly. In particular, method names must be consistent with the corresponding method implementations. Debugging method names remains an important topic in the literature, where various approaches analyze commonalities among method names in a large dataset to detect inconsistent method names and suggest better ones. We note that the state-of-the-art does not analyze the implemented code itself to assess consistency. We thus propose a novel automated approach to debugging method names based on the analysis of consistency between method names and method code. The approach leverages deep feature representation techniques adapted to the nature of each artifact. Experimental results on over 2.1 million Java methods show that we can achieve up to 15 percentage points improvement over the state-of-the-art, establishing a record performance of 67.9% F1- measure in identifying inconsistent method names. We further demonstrate that our approach yields up to 25% accuracy in suggesting full names, while the state-of-the-art lags far behind at 1.1% accuracy. Finally, we report on our success in fixing 66 inconsistent method names in a live study on projects in the wild.
@inproceedings{Liu0BKKKKT19,
title = {Learning to Spot and Refactor Inconsistent Method Names},
author = {Kui Liu and Dongsun Kim and Tegawende F. Bissyande and Taeyoung Kim and Kisub Kim and Anil Koyuncu and Suntae Kim and Yves Le Traon},
booktitle = {ICSE},
year = {2019},
doi = {10.1109/icse.2019.00019}
}