用GPT-4o迭代评估并优化代码质量,提升可读性与安全性。
On Iterative Evaluation and Enhancement of Code Quality Using GPT-4o
- 通过十维评分+反馈循环,自动评估代码质量
- 在Python和JavaScript上实现平均52.6%的改进率
- 适合希望自动化代码审查的开发者与团队
本文提出CodeQUEST框架,利用大语言模型(LLM)在可读性、可维护性、效率和安全性等多个维度上迭代评估并优化代码质量。该框架包含评估器(Evaluator)与优化器(Optimizer)两部分:评估器对代码进行十维评分,输出量化分数与定性总结;优化器根据反馈持续改进代码。基于精选的Python与JavaScript示例数据集实验表明,CodeQUEST能有效且稳健地评估代码质量,其结果与Pylint得分、Radon可维护性指数及Bandit扫描日志等代理指标具有显著相关性。整体代码质量平均提升52.6%。该研究展示了LLM在自动化代码质量评估与改进中的潜力,推动软件开发实践升级。代码已开源:https://github.com/jpmorganchase/CodeQuest。
原文摘要 · Abstract (English)
This paper introduces CodeQUEST, a novel framework leveraging Large Language Models (LLMs) to iteratively evaluate and enhance code quality across multiple dimensions, including readability, maintainability, efficiency, and security. The framework is divided into two main components: an Evaluator that assesses code quality across ten dimensions, providing both quantitative scores and qualitative summaries, and an Optimizer that iteratively improves the code based on the Evaluator's feedback. Our study demonstrates that CodeQUEST can effectively and robustly evaluate code quality, with its assessments aligning closely with established code quality metrics. Through a series of experiments using a curated dataset of Python and JavaScript examples, CodeQUEST demonstrated significant improvements in code quality, achieving a mean relative percentage improvement of 52.6%. The framework's evaluations were validated against a set of proxy metrics comprising of Pylint Score, Radon Maintainability Index, and Bandit output logs, showing a meaningful correlation. This highlights the potential of LLMs in automating code quality evaluation and improvement processes, presenting a significant advancement toward enhancing software development practices. The code implementation of the framework is available at: https://github.com/jpmorganchase/CodeQuest.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。