The following article investigates how large language models (LLMs) can be used to evaluate source code quality. A rapid literature review identified 23 relevant articles that addressed key questions about LLM-based code reviews. Based on the information collected, we developed a structured evaluation framework comprising twelve quantifiable metrics designed to systematically measure code quality across multiple dimensions. In order to compare LLMs as code reviewers with human developers, the created metrics were then used by both human developers and LLMs against 75 source code files. These files were curated to represent diverse coding practices, emphasising examples that demonstrate potential quality issues, antipatterns, and suboptimal implementations. A dedicated software platform was developed to automate the prompting and collection of evaluations from multiple LLMs, complemented by parallel human evaluations. Our study shows that certain LLMs can effectively evaluate source code quality with a high correlation with human expert review, with Claude Sonet showing the strongest agreement. We observed that LLMS assign higher scores than humans for complex dimensions such as the Liskov substitution principle and the dependence inversion principle. The cost analysis demonstrated a significant difference between the models, suggesting that GPT-4o-mini may offer the best balance of performance and economic efficiency for real-world applications (with the consideration of data privacy remaining an important factor).

错误:搜索内容不能为空,请输入英文关键词
错误:关键词超出字数限制,请精简
高级检索

LLMs as Code Review Agents: A Rapid Review and Experimental Evaluation with Human Expert Judges

  • Marcin Kawalerowicz,
  • Marcin Pietranik,
  • Krzysztof Stępniak

摘要

The following article investigates how large language models (LLMs) can be used to evaluate source code quality. A rapid literature review identified 23 relevant articles that addressed key questions about LLM-based code reviews. Based on the information collected, we developed a structured evaluation framework comprising twelve quantifiable metrics designed to systematically measure code quality across multiple dimensions. In order to compare LLMs as code reviewers with human developers, the created metrics were then used by both human developers and LLMs against 75 source code files. These files were curated to represent diverse coding practices, emphasising examples that demonstrate potential quality issues, antipatterns, and suboptimal implementations. A dedicated software platform was developed to automate the prompting and collection of evaluations from multiple LLMs, complemented by parallel human evaluations. Our study shows that certain LLMs can effectively evaluate source code quality with a high correlation with human expert review, with Claude Sonet showing the strongest agreement. We observed that LLMS assign higher scores than humans for complex dimensions such as the Liskov substitution principle and the dependence inversion principle. The cost analysis demonstrated a significant difference between the models, suggesting that GPT-4o-mini may offer the best balance of performance and economic efficiency for real-world applications (with the consideration of data privacy remaining an important factor).