Static Analysis tools have rules for several code quality issues and these rules are created by experts manually. In this paper, we address the problem of automatic synthesis of code quality rules from examples. We formulate the rule synthesis problem as synthesizing first order logic formulas over graph representations of code. We present a new synthesis algorithm RhoSynth that is based on Integer Linear Programming-based graph alignment for identifying code elements of interest to the rule. We bootstrap RhoSynth by leveraging code changes made by developers as the source of positive and negative examples. We also address rule refinement in which the rules are incrementally improved with additional user-provided examples. We validate RhoSynth by synthesizing more than 30 Java code quality rules. These rules have been deployed as part of a code review system in a company and their precision exceeds 75% based on developer feedback collected during live code-reviews. Through comparisons with recent baselines, we show that current state-of-the-art program synthesis approaches are unable to synthesize most of these rules.
翻译:静态分析工具对若干代码质量问题有规则, 这些规则由专家手工制定。 在本文中, 我们处理从示例中自动综合代码质量规则的问题。 我们将规则合成问题作为对代码图示中第一顺序逻辑公式的合成, 将代码质量规则综合起来。 我们提出了一个新的合成算法 RohoSynth, 以基于 Integer Linearning 编程的图形对齐为基础, 用于确定规则中感兴趣的代码要素 。 我们利用开发者对代码的修改作为正面和负面实例的来源, 来保护RhoSynth 。 我们还处理规则的完善问题, 规则在其中以其他用户提供的示例逐步改进。 我们通过合成超过30个 Java 代码质量规则来验证RhoSynth 。 这些规则是公司代码审查系统的一部分, 其精确度超过75% 。 我们通过对近期的基线进行比较, 显示当前最先进的程序合成方法无法综合大多数这些规则 。