Abstract
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.
Original language | English |
---|---|
Title of host publication | Proceedings - 2016 IEEE/ACM 38th IEEE International Conference on Software Engineering Companion, ICSE 2016 |
Place of Publication | Los Alamitos, CA |
Publisher | IEEE |
Pages | 428-439 |
Number of pages | 12 |
Volume | 1 |
ISBN (Electronic) | 978-1-4503-3900-1 |
DOIs | |
Publication status | Published - 14 May 2016 |
Event | 2016 IEEE/ACM 38th IEEE International Conference on Software Engineering, ICSE 2016 - Austin, United States Duration: 14 May 2016 → 22 May 2016 |
Conference
Conference | 2016 IEEE/ACM 38th IEEE International Conference on Software Engineering, ICSE 2016 |
---|---|
Country/Territory | United States |
City | Austin |
Period | 14/05/16 → 22/05/16 |