使用StackOverflow内容协助代码评审
Using StackOverflow content to assist in code review
摘要:
程序员的一个重要目标是最小化识别和纠正源代码中缺陷的成本。代码评审通常用于识别编程缺陷。然而,手动代码审查有一些缺点:a)它很耗时,b)结果是主观的,取决于审查者的技能。因此,非常需要一种用于协助代码审查的自动化方法。我们提出了一个工具,以协助在代码审查和结果,从我们的实验评估工具在不同的情况下。该工具利用专业程序员支持论坛(例如StackOverflow.com)提供的内容来确定给定源代码片段的潜在缺陷。缺陷程度以{可能有缺陷、中性、不太可能有缺陷}的等级表示。该工具中采用的基本思想是:a)识别StackOverflow上的讨论帖子的集合P,使得P中的每个p包含与正在审查的输入代码C充分相似的源代码片段。b)通过考虑P中的所有p来确定C有缺陷的可能性。我们的方法的一个新颖的方面是使用文档指纹比较两段源代码。我们选择的文档指纹技术的灵感来自源代码剽窃检测工具,它已被证明是非常成功的。在我们进行的验证我们方法有效性的实验中,来自300多个GitHub开源存储库的源代码样本被用作输入。在确定正确/相关结果方面,已达到90%以上的精度。
英文摘要:
An important goal for programmers is to minimize cost of identifying and correcting defects in source code. Code review is commonly used for identifying programming defects. However, manual code review has some shortcomings: a) it is time consuming, b) outcomes are subjective and depend on the skills of reviewers. An automated approach for assisting in code reviews is thus highly desirable. We present a tool for assisting in code review and results from our experiments evaluating the tool in different scenarios. The tool leveraged content available from professional programmer support forums (e.g. StackOverflow.com) to determine potential defectiveness of a given piece of source code. The defectiveness is expressed on the scale of {Likely defective, Neutral, Unlikely to be defective}. Basic idea employed in the tool is to: a) Identify a set P of discussion posts on StackOverflow such that each p in P contains source code fragment(s) which sufficiently resemble the input code C being reviewed. b) Determine the likelihood of C being defective by considering all p in P . A novel aspect of our approach is to use document fingerprinting for comparing two pieces of source code. Our choice of document fingerprinting technique is inspired by source code plagiarism detection tools where it has proven to be very successful. In the experiments that we performed to verify effectiveness of our approach source code samples from more than 300 GitHub open source repositories were taken as input. A precision of more than 90% in identifying correct/relevant results has been achieved.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。