arXiv:2602.07783cs.SEcs.AI2026-02中稿 · FSE2026被引 1

用自然语言自动生成代码规范检查工具配置,省去手动调试

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

  • 设计专用语言表达代码规则,实现跨语言统一配置
  • 生成配置在细粒度任务中准确率超70%,精度提升超100%
  • 适合需要快速部署代码规范的开发团队和工具链集成者

代码规范对保障团队与项目间代码质量至关重要。代码检查工具(linter)可检测违规行为,但手动配置复杂且耗时。面对编程语言、规范和工具的多样性和持续演化,配置工作重复且难以维护。为此,我们提出LintCFG,一种基于领域特定语言(DSL)与大模型结合的自动化配置生成方法,适用于任意编程语言、规范和检查工具。受编译器设计启发,先构建一个与工具无关、结构清晰、可读性强的DSL来表达编码规则;再将检查工具配置映射为DSL指令。针对自然语言描述的代码规范,系统通过解析生成DSL规则,匹配对应配置项,验证一致性后输出目标工具专属配置。在Java Checkstyle规范上实验显示,DSL表示的精确率与召回率均超90%,细粒度配置生成的准确率、精确率、召回率与F1值接近70%(部分超70%)。相比基线,精确率提升超100%。用户研究证实该方法显著提高开发者配置效率。进一步在JavaScript ESLint规范上验证了其跨语言通用性。

原文摘要 · Abstract (English)

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.

代码规范自动化配置大模型应用DSL

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。