arrow
返回

Refining ChatGPT-Generated Code: Characterizing and Mitigating Code Quality Issues

delete2024-06-04
delete8
delete
OA
AI
Y
Yue Liu
T
Thanh Le-Cong
R
Ratnadira Widyasari
C
Chakkrit Tantithamthavorn *
L
Li Li
X
Xuan-Bach D. Le
D
David Lo
DOI:10.1145/3643674delete
delete原文链接
delete原文求助
delete分享
delete收藏
摘要

摘要

En 中文
Since its introduction in November 2022, ChatGPT has rapidly gained popularity due to its remarkable ability in language understanding and human-like responses. ChatGPT, based on GPT-3.5 architecture, has shown great promise for revolutionizing various research fields, including code generation. However, the reliability and quality of code generated by ChatGPT remain unexplored, raising concerns about potential risks associated with the widespread use of ChatGPT-driven code generation. In this article, we systematically study the quality of 4,066 ChatGPT-generated programs of code implemented in two popular programming languages, i.e., Java and Python, for 2,033 programming tasks. The goal of this work is threefold. First, we analyze the correctness of ChatGPT on code generation tasks and uncover the factors that influence its effectiveness, including task difficulty, programming language, time that tasks are introduced, and program size. Second, we identify and characterize potential issues with the quality of ChatGPT-generated code. Last, we provide insights into how these issues can be mitigated. Experiments highlight that out of 4,066 programs generated by ChatGPT, 2,756 programs are deemed correct, 1,082 programs provide wrong outputs, and 177 programs contain compilation or runtime errors. Additionally, we further analyze other characteristics of the generated code through static analysis tools, such as code style and maintainability, and find that 1,930 ChatGPT-generated code snippets suffer from maintainability issues. Subsequently, we investigate ChatGPT's self-repairing ability and its interaction with static analysis tools to fix the errors uncovered in the previous step. Experiments suggest that ChatGPT can partially address these challenges, improving code quality by more than 20%, but there are still limitations and opportunities for improvement. Overall, our study provides valuable insights into the current limitations of ChatGPT and offers a roadmap for future research and development efforts to enhance the code generation capabilities of artificial intelligence models such as ChatGPT.
Keyword:
Automated code generation
ChatGPT
code analysis

期刊

A
ACM Transactions on Software Engineering and Methodology
IF:
6.2
论文数:
1.2K
被引数:
3.4K

机构

M
Monash University
学者数:
5.4W
论文数: 5.4W
被引数: 79
B
Beihang University
学者数:
5.2W
论文数: 4.1W
被引数: 37
S
Singapore Management University
学者数:
1.5K
论文数: 2.5K
被引数: 3.5K
U
university of melbourne
学者数:
5.7W
论文数: 5.4W
被引数: 69
学者 查看更多机构
引用论文

引用论文

Chronic myeloid leukemia in a patient with acquired immune deficiency syndrome: complete cytogenetic response with imatinib mesylate: report of a case and review of the literature
err2004-06-01
err0
PREAI
errApostolia-Maria Tsimberidou; Jorge Medina; Jorge Cortes; Adan Rios; Glisson Bonnie; Stefan Faderl; Hagop Kantarjian; Guillermo Garcia-Manero
err分享
err收藏
err分享
err收藏
err分享
err收藏
Peach Firmness Determination by Puncture Resistance, Drop Impact, and Sonic Impulse
err1994-01-01
err0
PREAI
errX. Zhang; M. L. Stone; D. Chen; N. O. Maness; G. H. Brusewitz
err分享
err收藏
MultiPL-E: A Scalable and Polyglot Approach to Benchmarking Neural Code GenerationMultiPL-E: 一种可扩展且多语言的神经代码生成基准测试方法
err2023-07-01
err28
errOAAI
errCassano, Federico; Gouwar, John; Nguyen, Daniel; Nguyen, Sydney; Phipps-Costin, Luna; Pinckney, Donald; Yee, Ming-Ho; Zi, Yangtian; Anderson, Carolyn Jane; Feldman, Molly Q.; Guha, Arjun; Greenberg, Michael; Jangda, Abhinav
err分享
err收藏
Identification of effective DNA barcodes for Triticum plants through chloroplast genome-wide analysis
err2017-12-01
err0
PREAI
errMohamed Awad; Ragab M. Fahmy; Kareem A. Mosa; Mohamed Helmy; Fawzy A. El-Feky
err分享
err收藏
Variable effects of temperature on insect herbivory温度对昆虫食草的可变影响
err2014-05-06
err0
errOAAI
errNathan P. Lemoine; Deron E. Burkepile; John D. Parker
err分享
err收藏
学者 查看更多内容