arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2410.21990cs.SE
收藏

理解代码审查中代码可理解性的改进

Understanding Code Understandability Improvements in Code Reviews

Delano Oliveira, Reydne Santos, Benedito de Oliveira, Martin Monperrus, Fernando Castor, Fernanda Madeiral

AI总结:

本研究通过分析GitHub上2,401条Java代码审查评论,发现超42%关注代码可理解性,归纳出八类改进关注点及补丁类型,并指出现有linter覆盖率不足30%,为开发专用机器学习模型和代码风格指南提供了可靠数据支持。

摘要:

动机:代码可理解性在软件开发中至关重要,因为开发者将58%到70%的时间用于阅读源代码。提升代码可理解性可以提高生产力并降低维护成本。问题:实验研究通常在受控环境中识别影响代码可理解性的因素,但忽略了项目文化、指南和开发者背景等现实世界的影响。忽视这些因素可能导致研究结果的外部有效性受限。目标:本研究假设代码审查者是代码质量专家,调查开发者如何通过代码审查评论提升代码可理解性。方法与结果:我们分析了GitHub上Java开源项目的2,401条代码审查评论,发现超过42%的评论专注于提升代码可理解性。我们进一步检查了385条专门与此方面相关的评论,并识别出八类关注点,如文档不充分和标识符不当。值得注意的是,83.9%的改进建议被接受并整合,其中不到1%后来被撤销。我们识别了多种提升可理解性的补丁类型,从删除未使用代码等简单更改到优化方法调用等依赖上下文的改进。此外,我们评估了四个知名linter标记这些问题的能力,发现它们覆盖不到30%,尽管许多问题可以很容易地作为新规则添加。启示:我们的发现鼓励开发提升代码可理解性的工具,因为被接受的更改可以作为专用机器学习模型的可靠训练数据。我们的数据集支持这种训练,并可为基于证据的代码风格指南的开发提供信息。数据可用性:我们的数据可在https://codeupcrc.github.io公开获取。

英文摘要:

Motivation: Code understandability is crucial in software development, as developers spend 58% to 70% of their time reading source code. Improving it can improve productivity and reduce maintenance costs. Problem: Experimental studies often identify factors influencing code understandability in controlled settings but overlook real-world influences like project culture, guidelines, and developers' backgrounds. Ignoring these factors may yield results with limited external validity. Objective: This study investigates how developers enhance code understandability through code review comments, assuming that code reviewers are specialists in code quality. Method and Results: We analyzed 2,401 code review comments from Java open-source projects on GitHub, finding that over 42% focus on improving code understandability. We further examined 385 comments specifically related to this aspect and identified eight categories of concerns, such as inadequate documentation and poor identifiers. Notably, 83.9% of suggestions for improvement were accepted and integrated, with fewer than 1% later reverted. We identified various types of patches that enhance understandability, from simple changes like removing unused code to context-dependent improvements such as optimizing method calls. Additionally, we evaluated four well-known linters for their ability to flag these issues, finding they cover less than 30%, although many could be easily added as new rules. Implications: Our findings encourage the development of tools to enhance code understandability, as accepted changes can serve as reliable training data for specialized machine-learning models. Our dataset supports this training and can inform the development of evidence-based code style guides. Data Availability: Our data is publicly available at https://codeupcrc.github.io.

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

↑