[Paper Review] Learning Quick Fixes from Code Repositories
This paper proposes Revisar, a tool that automatically discovers common Java code edit patterns—used as quick fixes—from revision histories in software repositories. By mining concrete edits across nine popular GitHub projects, Revisar identifies 89 reusable patterns, 64% of which were absent from existing code analyzers; a survey of 164 programmers showed 89% preference for the discovered fixes, and 60% of submitted pull requests were accepted, validating real-world utility.
Code analyzers such as Error Prone and FindBugs detect code patterns symptomatic of bugs, performance issues, or bad style. These tools express patterns as quick fixes that detect and rewrite unwanted code. However, it is difficult to come up with new quick fixes 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 their revision 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 patterns 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 the nine of the discovered patterns. Finally, we submitted 16 pull requests applying our patterns to 9 projects and, at the time of the writing, programmers accepted 6 (60%) 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.
Motivation & Objective
- To address the challenge of identifying useful, frequently applied code edit patterns for integration into static analysis tools.
- To enable toolsmiths to prioritize quick fixes based on actual developer practices rather than ad-hoc heuristics.
- To discover new, empirically validated quick fixes by analyzing real-world code changes across multiple open-source projects.
- To evaluate the practicality and developer preference of mined patterns through surveys and real-world pull request submissions.
Proposed method
- Revisar compares consecutive code revisions in version control histories to extract concrete code edits.
- It applies a syntactic abstraction technique to generalize concrete edits into reusable edit patterns.
- It clusters similar edits into abstract patterns using a sound and complete matching algorithm.
- It leverages a Refaster-like syntax to represent discovered patterns as executable quick fixes.
- It validates patterns via a large-scale survey of 164 developers and real-world pull request submissions to production repositories.
Experimental results
Research questions
- RQ1Which code edit patterns are commonly applied by developers across multiple open-source projects?
- RQ2How do developers perceive the usefulness of quick fixes discovered from real revision histories?
- RQ3To what extent can mined edit patterns be successfully contributed back to production codebases?
- RQ4How do the discovered patterns compare to those already present in popular code analysis tools?
Key findings
- Revisar discovered 89 distinct edit patterns that appeared in three or more of nine popular GitHub projects.
- 64% of the discovered patterns were not present in existing code analysis tools such as FindBugs, PMD, or Error Prone.
- In a survey of 164 programmers, 89% expressed support for the majority of the nine tested quick fixes.
- Out of 16 pull requests submitting the discovered fixes to real projects, 60% were accepted by maintainers.
- The technique successfully identified a well-known null-safety pattern (e.g., using "str.equals(obj)" instead of "obj.equals(str)") that was missing from Google’s Error Prone.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.