Styler:学习格式约定以修复Checkstyle冲突
Styler: learning formatting conventions to repair Checkstyle violations
摘要:
确保格式约定的一致使用是现代软件质量保证的一个重要方面。虽然格式约定违反可以自动检测的格式检查器实现的链接器,有没有令人满意的解决方案来修复它们。手动修复违反格式化约定的情况是浪费开发人员的时间,并且代码格式化程序不会考虑开发人员为使用的linter采用和配置的约定。在本文中,我们提出了Styler,一个工具,致力于修复格式检查器使用机器学习方法提出的格式规则违规。对于给定的项目,Styler首先通过在无违规源代码文件中注入违反项目特定规则的行为来生成训练数据。然后,它通过向长短期记忆神经网络提供编码成令牌序列的训练数据来学习修复。最后,它使用训练好的模型预测实际格式违规的修复。目前,Styler支持一个检查器Checkstyle,这是一个高度可配置和流行的Java格式检查器。在一项实证评估中,Styler修复了从104个GitHub项目中挖掘出的26,791个Checkstyle违规中的41%。此外,我们将Styler与IntelliJ插件CheckStyle-IDEA以及基于机器学习的代码格式化器Naturalize和CodeBuff进行了比较。我们发现,Styler修复了一组不同的Checkstyle规则(24/25规则)的违规行为,与其他系统相比,它生成的修复量较小,并且一旦在项目上训练,它就能在几秒钟内预测修复。通过手动分析,我们确定了Styler无法成功生成正确修复的情况,这可以指导Styler的进一步改进。最后,结果表明,Styler可以帮助开发人员修复Checkstyle格式冲突。
英文摘要:
Ensuring the consistent usage of formatting conventions is an important aspect of modern software quality assurance. While formatting convention violations can be automatically detected by format checkers implemented in linters, there is no satisfactory solution for repairing them. Manually fixing formatting convention violations is a waste of developer time and code formatters do not take into account the conventions adopted and configured by developers for the used linter. In this paper, we present Styler, a tool dedicated to fixing formatting rule violations raised by format checkers using a machine learning approach. For a given project, Styler first generates training data by injecting violations of the project-specific rules in violation-free source code files. Then, it learns fixes by feeding long short-term memory neural networks with the training data encoded into token sequences. Finally, it predicts fixes for real formatting violations with the trained models. Currently, Styler supports a single checker, Checkstyle, which is a highly configurable and popular format checker for Java. In an empirical evaluation, Styler repaired 41% of 26,791 Checkstyle violations mined from 104 GitHub projects. Moreover, we compared Styler with the IntelliJ plugin CheckStyle-IDEA and the machine-learning-based code formatters Naturalize and CodeBuff. We found out that Styler fixes violations of a diverse set of Checkstyle rules (24/25 rules), generates smaller repairs in comparison to the other systems, and predicts repairs in seconds once trained on a project. Through a manual analysis, we identified cases in which Styler does not succeed to generate correct repairs, which can guide further improvements in Styler. Finally, the results suggest that Styler can be useful to help developers repair Checkstyle formatting violations.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。