NameChecker: Detecting Inconsistency between Method Names and Method Bodies

Kejun Li, Taiming Wang, Hui Liu

Research output: Chapter in Book/Report/Conference proceedingConference contributionpeer-review

Abstract

Methods are basic elements for functional organization in software applications. A high-quality method name should clearly express its function, and help developers understand its usages quickly without reading through the lengthy and complex method body. However, in some cases, method names could be inconsistent with their functional implementations. The inconsistency in turn may result in inaccurate interpretation of methods, and even buggy method invocations. To this end, in this paper, we propose a deep learning-based approach, called NameChecker, to detecting the inconsistency between method names and their corresponding method bodies. NameChecker extracts lexical and structural features of source code by static code analysis. Based on the extracted features, NameChecker employs deep learning techniques (i.e., LSTM, and Attention mechanism) to predict whether the given method name is consistent with its implementation. Different from other deep learning based approaches to inconsistency detection, NameChecker avoids the generation (recommendation) of method names. Empirical studies suggested that generated method names are often incorrect, and thus avoiding method name generation may significantly improve the accuracy of NameChecker. We evaluate NameChecker on open-source applications, and our evaluation results suggest that NameChecker improves the state of the art by increasing the F1-score from 66.7% to 73.4%.

Original languageEnglish
Title of host publicationProceedings - 2021 28th Asia-Pacific Software Engineering Conference, APSEC 2021
PublisherIEEE Computer Society
Pages22-31
Number of pages10
ISBN (Electronic)9781665437844
DOIs
Publication statusPublished - 2021
Event28th Asia-Pacific Software Engineering Conference, APSEC 2021 - Virtual, Online, Taiwan, Province of China
Duration: 6 Dec 20219 Dec 2021

Publication series

NameProceedings - Asia-Pacific Software Engineering Conference, APSEC
Volume2021-December
ISSN (Print)1530-1362

Conference

Conference28th Asia-Pacific Software Engineering Conference, APSEC 2021
Country/TerritoryTaiwan, Province of China
CityVirtual, Online
Period6/12/219/12/21

Keywords

  • Deep Learning
  • Inconsistent
  • Method Name
  • Software Quality
  • Static Analysis

Fingerprint

Dive into the research topics of 'NameChecker: Detecting Inconsistency between Method Names and Method Bodies'. Together they form a unique fingerprint.

Cite this