Not logged in.

Contribution Details

Type Conference or Workshop Paper
Scope Discipline-based scholarship
Published in Proceedings Yes
Title On the "naturalness" of buggy code
Organization Unit
Authors
  • Baishakhi Ray
  • Vincent Hellendoorn
  • Saheel Godhane
  • Zhaopeng Tu
  • Alberto Bacchelli
  • Premkumar Devanbu
Presentation Type paper
Item Subtype Original Work
Refereed Yes
Status Published in final form
Language
  • English
ISBN 9781450339001
Page Range 428 - 439
Event Title the 38th International Conference
Event Type conference
Event Location Austin, Texas
Event Start Date June 14 - 2016
Event End Date June 22 - 2016
Place of Publication New York, New York, USA
Publisher ACM Press
Abstract Text Real software, the kind working programmers produce by the kLOC to solve real-world problems, tends to be "natural", like speech or natural language; it tends to be highly repetitive and predictable. Researchers have captured this naturalness of software through statistical models and used them to good effect in suggestion engines, porting tools, coding standards checkers, and idiom miners. This suggests that code that appears improbable, or surprising, to a good statistical language model is "unnatural" in some sense, and thus possibly suspicious. In this paper, we investigate this hypothesis. We consider a large corpus of bug fix commits (ca. 7,139), from 10 different Java projects, and focus on its language statistics, evaluating the naturalness of buggy code and the corresponding fixes. We find that code with bugs tends to be more entropic (i.e. unnatural), becoming less so as bugs are fixed. Ordering files for inspection by their average entropy yields cost-effectiveness scores comparable to popular defect prediction methods. At a finer granularity, focusing on highly entropic lines is similar in cost-effectiveness to some well-known static bug finders (PMD, FindBugs) and ordering warnings from these bug finders using an entropy measure improves the cost-effectiveness of inspecting code implicated in warnings. This suggests that entropy may be a valid, simple way to complement the effectiveness of PMD or FindBugs, and that search-based bug-fixing methods may benefit from using entropy both for fault-localization and searching for fixes.
Digital Object Identifier 10.1145/2884781.2884848
Other Identification Number merlin-id:20277
PDF File Download from ZORA
Export BibTeX
EP3 XML (ZORA)