Table of Contents
Fetching ...

Demystifying Code Snippets in Code Reviews: A Study of the OpenStack and Qt Communities and A Practitioner Survey

Beiqi Zhang, Liming Fu, Peng Liang, Jiaxin Yu, Chong Wang

TL;DR

This study investigates the role of code snippets in code reviews through a mixed-methods approach that combines Gerrit-based mining of OpenStack (Nova, Neutron) and Qt (Qt Base, Qt Creator) with an industrial survey of 63 practitioners. It finds that code snippets are relatively rare (4.6% of review comments) and predominantly provided by reviewers, mainly serving as suggestions to improve code implementation and maintainability. Developer acceptance of snippet suggestions is high (62.1%), yet varies by purpose, with code-style suggestions being more readily accepted than optimization-focused ones. The analysis identifies 11 scenarios for snippet usage, 11 reasons for non-acceptance (chiefly disagreement between reviewer and developer), and four desired characteristics of snippets (notably understandability and fit with existing code). The work offers actionable guidelines for practitioners and suggests tooling and future research to enhance communication and efficiency in code reviews.

Abstract

Code review is widely known as one of the best practices for software quality assurance in software development. In a typical code review process, reviewers check the code committed by developers to ensure the quality of the code, during which reviewers and developers would communicate with each other in review comments to exchange necessary information. As a result, understanding the information in review comments is a prerequisite for reviewers and developers to conduct an effective code review. Code snippet, as a special form of code, can be used to convey necessary information in code reviews. For example, reviewers can use code snippets to make suggestions or elaborate their ideas to meet developers' information needs in code reviews. However, little research has focused on the practices of providing code snippets in code reviews. To bridge this gap, we conduct a mixed-methods study to mine information and knowledge related to code snippets in code reviews, which can help practitioners and researchers get a better understanding about using code snippets in code review. Specifically, our study includes two phases: mining code review data and conducting practitioners' survey. The study results highlight that reviewers can provide code snippets in appropriate scenarios to meet developers' specific information needs in code reviews, which will facilitate and accelerate the code review process.

Demystifying Code Snippets in Code Reviews: A Study of the OpenStack and Qt Communities and A Practitioner Survey

TL;DR

This study investigates the role of code snippets in code reviews through a mixed-methods approach that combines Gerrit-based mining of OpenStack (Nova, Neutron) and Qt (Qt Base, Qt Creator) with an industrial survey of 63 practitioners. It finds that code snippets are relatively rare (4.6% of review comments) and predominantly provided by reviewers, mainly serving as suggestions to improve code implementation and maintainability. Developer acceptance of snippet suggestions is high (62.1%), yet varies by purpose, with code-style suggestions being more readily accepted than optimization-focused ones. The analysis identifies 11 scenarios for snippet usage, 11 reasons for non-acceptance (chiefly disagreement between reviewer and developer), and four desired characteristics of snippets (notably understandability and fit with existing code). The work offers actionable guidelines for practitioners and suggests tooling and future research to enhance communication and efficiency in code reviews.

Abstract

Code review is widely known as one of the best practices for software quality assurance in software development. In a typical code review process, reviewers check the code committed by developers to ensure the quality of the code, during which reviewers and developers would communicate with each other in review comments to exchange necessary information. As a result, understanding the information in review comments is a prerequisite for reviewers and developers to conduct an effective code review. Code snippet, as a special form of code, can be used to convey necessary information in code reviews. For example, reviewers can use code snippets to make suggestions or elaborate their ideas to meet developers' information needs in code reviews. However, little research has focused on the practices of providing code snippets in code reviews. To bridge this gap, we conduct a mixed-methods study to mine information and knowledge related to code snippets in code reviews, which can help practitioners and researchers get a better understanding about using code snippets in code review. Specifically, our study includes two phases: mining code review data and conducting practitioners' survey. The study results highlight that reviewers can provide code snippets in appropriate scenarios to meet developers' specific information needs in code reviews, which will facilitate and accelerate the code review process.
Paper Structure (29 sections, 9 figures, 15 tables)

This paper contains 29 sections, 9 figures, 15 tables.

Figures (9)

  • Figure 1: Overview of the mixed-methods research process
  • Figure 2: Example of a developer accepting a reviewer's code snippet suggestion
  • Figure 3: Distribution of software development experience of the participants
  • Figure 4: Distribution of how often industrial developers provide code snippets in code reviews
  • Figure 5: Category of purposes of code snippets provided by reviewers in code reviews
  • ...and 4 more figures