arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2103.11446cs.SE
收藏

通过代码评审理解代码错误检测:对OpenStack社区的研究

Understanding Code Smell Detection via Code Review: A Study of the OpenStack Community

Xiaofeng Han, Amjed Tahir, Peng Liang, Steve Counsell, Yajing Luo

摘要:

代码评审在软件质量控制中起着重要的作用。一个典型的评审过程包括仔细检查一段代码,试图找到缺陷和其他质量问题/违规。可能影响软件质量的一种类型的问题是代码气味-即,可能导致缺陷或维护问题的不良编程实践。然而,我们对在代码审查过程中识别代码气味的程度知之甚少。为了研究代码审查中识别出的代码气味背后的概念,以及审查者建议和开发人员采取什么行动来响应识别出的气味,我们使用两个最活跃的OpenStack项目(Nova和Neutron)对代码审查中的代码气味进行了实证研究。我们手动检查了通过关键字搜索和随机选择获得的19,146条评论,并获得了1,190条与气味相关的评论,以研究代码气味的原因以及针对识别出的气味采取的行动。我们的分析发现:1)代码气味通常不会在代码审查中被识别出来,2)气味通常是由违反编码约定引起的,3)审查人员通常会提供建设性的反馈,包括修复(重构)建议,以帮助开发人员消除气味,4)开发人员通常会遵循这些建议并采取行动。我们的研究结果表明:1)开发人员应该在他们的项目中严格遵循编码惯例,以避免引入代码气味; 2)基于审查的代码气味检测被开发人员认为是一种值得信赖的方法,主要是因为审查是上下文敏感的(因为审查者更了解代码的上下文,因为他们是项目开发团队的一部分)。

英文摘要:

Code review plays an important role in software quality control. A typical review process would involve a careful check of a piece of code in an attempt to find defects and other quality issues/violations. One type of issues that may impact the quality of the software is code smells - i.e., bad programming practices that may lead to defects or maintenance issues. Yet, little is known about the extent to which code smells are identified during code reviews. To investigate the concept behind code smells identified in code reviews and what actions reviewers suggest and developers take in response to the identified smells, we conducted an empirical study of code smells in code reviews using the two most active OpenStack projects (Nova and Neutron). We manually checked 19,146 review comments obtained by keywords search and random selection, and got 1,190 smell-related reviews to study the causes of code smells and actions taken against the identified smells. Our analysis found that 1) code smells were not commonly identified in code reviews, 2) smells were usually caused by violation of coding conventions, 3) reviewers usually provided constructive feedback, including fixing (refactoring) recommendations to help developers remove smells, and 4) developers generally followed those recommendations and actioned the changes. Our results suggest that 1) developers should closely follow coding conventions in their projects to avoid introducing code smells, and 2) review-based detection of code smells is perceived to be a trustworthy approach by developers, mainly because reviews are context-sensitive (as reviewers are more aware of the context of the code given that they are part of the project's development team).

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑