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

Still Manual? 通过基于 DSL 的 LLM 编译实现自动代码规范的 linter 配置

Still Manual? Automated Linter Configuration via DSL-Based LLM Compilation of Coding Standards

Zejun Zhang, Yixin Gan, Zhenchang Xing, Tian Zhang, Yi Li, Xiwei Xu, Qinghua Lu, Liming Zhu

AI总结:

本文提出 LintCFG,一种基于 DSL 的 LLM 编译方法,用于自动生成功能规范的 linter 配置,提升开发者效率。

摘要:

代码规范对于在团队和项目中保持一致的高质量代码至关重要。linter 帮助开发者通过检测代码违规来执行这些规范。然而,手动配置 linter 是复杂的且需要专业知识,编程语言、代码规范和 linter 的多样性和演变导致了重复且维护强度高的配置工作。为了减少手动工作量,我们提出了 LintCFG,一种基于领域特定语言(DSL)的 LLM 编译方法,用于自动化代码规范的 linter 配置生成,不依赖于编程语言、代码规范和 linter。受编译器设计的启发,我们首先设计了一个 DSL 来以工具无关、结构化、可读且精确的方式表达代码规则。然后,我们将 linter 配置构建到 DSL 配置指令中。对于给定的自然语言代码规范,编译过程将其解析为 DSL 代码规范,将其与 DSL 配置指令匹配以设置配置名称、选项名称和值,并验证规范与配置之间的一致性,最后生成特定 linter 的配置。在 Java 代码规范的 Checkstyle 实验中,我们的方法在 DSL 表示中实现了超过 90% 的精度和召回率,在细粒度 linter 配置生成中,准确率、精度、召回率和 F1 分数接近 70%(有些超过 70%)。值得注意的是,我们的方法在精度方面比基线高出超过 100%。进一步的用户研究显示,我们的方法提高了开发者在配置代码规范的 linter 时的效率。最后,我们通过为 JavaScript 代码规范生成 ESLint 配置,展示了该方法的通用性,展示了其在其他编程语言、代码规范和 linter 上的广泛适用性。

英文摘要:

Coding standards are essential for maintaining consistent and high-quality code across teams and projects. Linters help developers enforce these standards by detecting code violations. However, manual linter configuration is complex and expertise-intensive, and the diversity and evolution of programming languages, coding standards, and linters lead to repetitive and maintenance-intensive configuration work. To reduce manual effort, we propose LintCFG, a domain-specific language (DSL)-driven, LLM-based compilation approach to automate linter configuration generation for coding standards, independent of programming languages, coding standards, and linters. Inspired by compiler design, we first design a DSL to express coding rules in a tool-agnostic, structured, readable, and precise manner. Then, we build linter configurations into DSL configuration instructions. For a given natural language coding standard, the compilation process parses it into DSL coding standards, matches them with the DSL configuration instructions to set configuration names, option names and values, verifies consistency between the standards and configurations, and finally generates linter-specific configurations. Experiments with Checkstyle for Java coding standard show that our approach achieves over 90% precision and recall in DSL representation, with accuracy, precision, recall, and F1-scores close to 70% (with some exceeding 70%) in fine-grained linter configuration generation. Notably, our approach outperforms baselines by over 100% in precision. A user study further shows that our approach improves developers' efficiency in configuring linters for coding standards. Finally, we demonstrate the generality of the approach by generating ESLint configurations for JavaScript coding standards, showcasing its broad applicability across other programming languages, coding standards, and linters.

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

↑