通过现代代码审查检测代码气味:对OpenStack和Qt社区的研究
Code Smells Detection via Modern Code Review: A Study of the OpenStack and Qt Communities
摘要:
代码评审在软件质量控制中起着重要的作用,它可以检测和定位缺陷和其他质量问题。可能影响软件质量的一种问题是代码气味。然而,我们对现代代码审查中代码气味的识别程度知之甚少。为了研究现代代码审查中识别出的代码气味背后的概念,以及审查者建议和开发人员采取什么行动来响应识别出的气味,我们通过分析来自OpenStack(Nova和Neutron)和Qt(Qt Base和Qt Creator)社区的四个大型开源项目的审查,对代码审查中的代码气味进行了研究。我们手动检查了通过关键字搜索和随机选择获得的总共25,415条代码审查评论,并确定了1,539条与气味相关的评论。我们的分析发现:1)代码气味在代码评审中通常不会被识别出来,2)气味通常是由违反编码约定引起的,3)评审人员通常会提供建设性的反馈,包括修复(重构)建议,以帮助开发人员消除气味,4)开发人员通常遵循这些建议并采取行动的变化,5)一旦确定由审查,开发人员通常花费不到一周的时间来修复气味,以及6)开发人员选择忽略所识别的气味的主要原因是不值得修复气味。我们的研究结果表明:1)开发人员应该在他们的项目中严格遵循编码惯例,以避免引入代码气味,2)基于审查的代码气味检测被开发人员认为是一种值得信赖的方法,主要是因为审查是上下文敏感的(由于评审人员是项目开发团队的一部分,因此他们更了解代码的上下文),以及3)需要充分考虑程序上下文以便做出是否立即修复所识别的代码气味的决定。
英文摘要:
Code review that detects and locates defects and other quality issues plays an important role in software quality control. One type of issue that may impact the quality of software is code smells. Yet, little is known about the extent to which code smells are identified during modern code review. To investigate the concept behind code smells identified in modern code review and what actions reviewers suggest and developers take in response to the identified smells, we conducted a study of code smells in code reviews by analyzing reviews from four large open source projects from the OpenStack (Nova and Neutron) and Qt (Qt Base and Qt Creator) communities. We manually checked a total of 25,415 code review comments obtained by keywords search and random selection, and identified 1,539 smell-related reviews. 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, 4) developers generally followed those recommendations and actioned the changes, 5) once identified by reviewers, it usually takes developers less than one week to fix the smells, and 6) the main reason why developers chose to ignore the identified smells is not worth fixing the smell. Our results suggest that: 1) developers should closely follow coding conventions in their projects to avoid introducing code smells, 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), and 3) program context needs to be fully considered in order to make a decision of whether to fix the identified code smell immediately.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。