Skip to main content
QUICK REVIEW

[论文解读] Learning Quick Fixes from Code Repositories

Reudismam Rolim de Sousa, Gustavo Soares|arXiv (Cornell University)|Mar 10, 2018
Software Engineering Research参考文献 22被引用 17
一句话总结

本文提出 Revisar,一种自动从软件仓库的版本历史中发现常见 Java 代码编辑模式(用作快速修复)的工具。通过挖掘九个流行 GitHub 项目中的具体编辑操作,Revisar 识别出 89 个可重用的模式,其中 64% 的模式在现有代码分析器中缺失;对 164 名程序员的调查显示,89% 的受访者偏好所发现的修复方案,且 60% 的提交 Pull Request 获得接受,验证了其在实际场景中的实用性。

ABSTRACT

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.

研究动机与目标

  • 为解决在静态分析工具中集成有用且频繁应用的代码编辑模式这一挑战。
  • 使工具开发者能够基于实际开发实践而非随意启发式方法来优先选择快速修复方案。
  • 通过分析多个开源项目的实际代码变更,发现新的、经实证验证的快速修复方案。
  • 通过调查和真实项目的 Pull Request 提交,评估所挖掘模式的实用性及开发者的偏好。

提出的方法

  • Revisar 比较版本控制历史中连续的代码版本,以提取具体的代码编辑操作。
  • 它应用语法抽象技术,将具体编辑操作泛化为可重用的编辑模式。
  • 它使用一种可靠且完备的匹配算法,将相似编辑聚类为抽象模式。
  • 它采用类似 Refaster 的语法,将发现的模式表示为可执行的快速修复。
  • 它通过大规模调查 164 名开发者的问卷和向生产仓库提交真实 Pull Request 的方式,对模式进行验证。

实验结果

研究问题

  • RQ1在多个开源项目中,开发者普遍应用了哪些代码编辑模式?
  • RQ2开发者如何看待从真实版本历史中发现的快速修复的实用性?
  • RQ3所挖掘的编辑模式在多大程度上可以成功贡献回生产代码库?
  • RQ4所发现的模式与现有主流代码分析工具中已有的模式相比如何?

主要发现

  • Revisar 发现了 89 种独立的编辑模式,这些模式在九个流行 GitHub 项目中的三个或以上项目中出现。
  • 所发现的模式中 64% 在现有的代码分析工具(如 FindBugs、PMD 或 Error Prone)中不存在。
  • 在对 164 名程序员的调查中,89% 的受访者表示支持所测试的九个快速修复中的大多数。
  • 在 16 个将所发现修复提交至真实项目的 Pull Request 中,有 60% 获得维护者接受。
  • 该技术成功识别出一个著名的空安全模式(例如,使用 "str.equals(obj)" 而非 "obj.equals(str)"),而该模式在 Google 的 Error Prone 中缺失。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。