STYLE-ANALYZER:使用可解释的无监督算法修复代码风格不一致
STYLE-ANALYZER: fixing code style inconsistencies with interpretable unsupervised algorithms
摘要:
源代码审查是手动的,耗时且昂贵。人的参与应该集中在分析程序最相关的方面,比如逻辑和可维护性,而不是修改风格、语法或格式缺陷。一些具有linting功能的工具可以自动格式化代码,并报告支持的程序设计语言的各种样式冲突。它们基于领域专家编写的规则,因此,它们的配置通常是繁琐的,并且给定的规则集覆盖所有可能的角落情况是不切实际的。存在一些基于机器学习的解决方案,但它们仍然是不可解释的黑箱。本文介绍了STYLE-ANALYZER,一个新的开源工具,使用决策树森林模型自动修复代码格式违规,该模型适用于每个代码库,完全无监督。STYLE-ANALYZER构建在我们新颖的辅助代码审查框架Lookout之上。它准确地挖掘每个分析的Git存储库的格式样式,并使用紧凑的人类可读规则表达发现的格式模式。然后STYLE-ANALYZER可以以代码评审注释的形式建议风格不一致的修复。我们评估的输出质量和实际相关性的风格分析,证明它可以重现原始风格的高精度,测量19个流行的JavaScript项目,并显示它产生有前途的结果,在修复真正的风格错误。STYLE-ANALYZER包括一个Web应用程序,用于可视化规则是如何触发的。我们在GitHub上发布STYLE-ANALYZER作为可重用和可扩展的开源软件包,以造福社区。
英文摘要:
Source code reviews are manual, time-consuming, and expensive. Human involvement should be focused on analyzing the most relevant aspects of the program, such as logic and maintainability, rather than amending style, syntax, or formatting defects. Some tools with linting capabilities can format code automatically and report various stylistic violations for supported programming languages. They are based on rules written by domain experts, hence, their configuration is often tedious, and it is impractical for the given set of rules to cover all possible corner cases. Some machine learning-based solutions exist, but they remain uninterpretable black boxes. This paper introduces STYLE-ANALYZER, a new open source tool to automatically fix code formatting violations using the decision tree forest model which adapts to each codebase and is fully unsupervised. STYLE-ANALYZER is built on top of our novel assisted code review framework, Lookout. It accurately mines the formatting style of each analyzed Git repository and expresses the found format patterns with compact human-readable rules. STYLE-ANALYZER can then suggest style inconsistency fixes in the form of code review comments. We evaluate the output quality and practical relevance of STYLE-ANALYZER by demonstrating that it can reproduce the original style with high precision, measured on 19 popular JavaScript projects, and by showing that it yields promising results in fixing real style mistakes. STYLE-ANALYZER includes a web application to visualize how the rules are triggered. We release STYLE-ANALYZER as a reusable and extendable open source software package on GitHub for the benefit of the community.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。