Learning Quick Fixes from Code Repositories - Rolim, Reudismam; Soares, Gustavo; Gheyi, Rohit; Barik, Titus; D’Antoni, Loris (Brazilian Symposium on Software Engineering, 2021)
Code analyzers such as Error Prone and FindBugs detect code pat-terns symptomatic of bugs, performance issues, or bad style. These tools express patterns as quick fixes that detect and rewrite un-wanted code. However, it is difficult to come up with new quickfixes and decide which ones are useful and frequently appear in real code. We propose to rely on the collective wisdom of programmers and learn quick fixes from revision histories in software repositories. We present Revisar, a tool for discovering common Java edit patterns in code repositories. Given code repositories and theirrevision histories, Revisar(i) identifies code edits from revisions and (ii) clusters edits into sets that can be described using an edit pattern. The designers of code analyzers can then inspect the pat-terns and add the corresponding quick fixes to their tools. We ran Revisar on nine popular GitHub projects, and it discovered 89 useful edit patterns that appeared in 3 or more projects. Moreover, 64%of the discovered patterns did not appear in existing tools. We then conducted a survey with 164 programmers from 124 projects and found that programmers significantly preferred eight out of thenine of the discovered patterns. Finally, we submitted 16 pull re-quests applying our patterns to 9 projects and, at the time of the writing, programmers accepted 7 (63.6%) of them. The results of this work aid toolsmiths in discovering quick fixes and making informed decisions about which quick fixes to prioritize based on patterns programmers actually apply in practice.