Cited by 128Software Engineering ResearchSoftware Testing and Debugging TechniquesTeaching and Learning Programming

No Need to Lift a Finger Anymore? Assessing the Quality of Code Generation by ChatGPT

Open access
Liu, Zhijie, Tang, Yutian, Luo, Xiapu, Zhou, Yuming, Zhang, Liang Feng·2024·IEEE Transactions on Software Engineering

Abstract

Large language models (LLMs) have demonstrated impressive capabilities across various natural language processing (NLP) tasks, such as machine translation, question answering, summarization, and so on. Additionally, LLMs are also highly valuable in supporting software engineering tasks, particularly in the field of code generation. Automatic code generation is a process of automatically generating source code or executable code based on given specifications or requirements, improving developer productivity. In this study, we perform a systematic empirical assessment to the quality of code generation usingChatGPT, a recent state-of-the-art product LLM. We leverage 728 algorithm problems in five languages (i.e., C, C++, Java, Python, and JavaScript) and 18 CWEs with 54 code scenarios for the code generation task. Our evaluation encompasses a comprehensive analysis of code snippets generated byChatGPT, focusing on three critical aspects: correctness, complexity, and security. We also specifically investigateChatGPT’s ability to engage in multi-round fixing process (i.e.,ChatGPT’s dialog ability, chatting between users andChatGPTfor fixing generated buggy code) of facilitating code generation. By delving into the generated code and examining the experimental results, this work provides valuable insights into the performance ofChatGPTin tackling code generation tasks over the three critical aspects. The experimental results demonstrate that (1)ChatGPTis better at generating functionally correct code for problems before 2021 in different languages than problems after 2021 with 48.14% advantage in Accepted rate on judgment platform, butChatGPT’s ability to directly fix erroneous code with multi-round fixing process to achieve correct functionality is relatively weak; (2) the distribution of cyclomatic and cognitive complexity levels for code snippets in different languages varies. Furthermore, the multi-round fixing process withChatGPTgenerally preserves or increases the complexity levels of code snippets; (3) in algorithm scenarios with languages of C, C++, and Jave, and CWE scenarios with languages of C and Python3, the code generated byChatGPThas relevant vulnerabilities. However, the multi-round fixing process for vulnerable code snippets demonstrates promising results, with more than 89% of vulnerabilities successfully addressed; and (4) code generation may be affected byChatGPT’s non-determinism factor, resulting in variations of code snippets in functional correctness, complexity, and security. Overall, our findings uncover potential issues and limitations that arise in theChatGPT-based code generation and lay the groundwork for improving AI and LLM-based code generation techniques.

Integrity signals

Registry

Crossref · 10.1109/tse.2024.3392499

Cites

19 of 19 references verified0 citation errors · 0 not checkable

Statistics

Recomputing p-values needs the paper’s full text.

Claims the paper makes

We couldn’t retrieve this paper’s full text, so its claims and self-check weren’t run. The registry and citation checks still apply.

Claims other papers make about this one

Each is checked against this paper’s own text: does it say what the citing paper says it does?

  • CyberBench is a domain-specific, multi-task benchmarking tool for evaluating LLMs' capabilities in cybersecurity tasks.

    “CyberBench(Liu etal. 2024f) is a domain-specific, multi-task benchmarking tool for evaluating LLMs' capabilities in cybersecurity tasks.”

    From When LLMs meet cybersecurity: a systematic literature review (2025) · cites this paper as Liu et al. 2024f

  • Liu et al. (2024e) proposes GPTDroid, which formulates GUI testing as a question and answering task where the LLM chats with mobile apps by passing GUI page information to generate testing scripts.

    “Liu et al. (2024e) addresses the challenge of automated Graphical User Interface (GUI) testing for mobile applications. They propose a novel approach called GPTDroid that formulates the GUI testing as a question and answering (Q&A) task, where the LLM is asked to chat with the mobile apps by passing GUI page information to generate testing scripts.”

    From When LLMs meet cybersecurity: a systematic literature review (2025) · cites this paper as Liu et al. (2024e)

  • Liu et al. (2024g)'s results reveal that while ChatGPT is able to generate functionally correct code, it encounters challenges in complex reasoning and ensuring code security.

    “The results reveal that while ChatGPT is able to generate functionally correct code, it encounters challenges in complex reasoning and ensuring code security.”

    From When LLMs meet cybersecurity: a systematic literature review (2025) · cites this paper as Liu et al. (2024g)

Cites

Flagged first, then by citations

Cited by

Sorted by citations

Authors
Liu, Z., Tang, Y., Luo, X., Zhou, Y., & Zhang, L. F.
Affiliations
  • ShanghaiTech University (CN)
  • University of Glasgow (GB)
  • Hong Kong Polytechnic University (HK)
  • Nanjing University (CN)
Venue
IEEE Transactions on Software Engineering
Published
2024-06
Volume
50
Issue
6
Pages
1548-1584
ISSN
  • 0098-5589 (ISSN-L)
  • 1939-3520
  • 2326-3881
OpenAlex
W4395029328
Cited by
128
References
19
Citations by year
2026: 35 · 2025: 69 · 2024: 24
FWCI
48.13
Type
journal article
Language
en
Open access
Locations
  • IEEE Transactions on Software Engineering (publishedVersion)
  • ENLIGHTEN (Jurnal Bimbingan dan Konseling Islam) (acceptedVersion, cc-by-sa)
  • arXiv (Cornell University) (submittedVersion, cc-by)
  • arXiv (Cornell University) (cc-by)
Funders
  • National Natural Science Foundation of China (62172205, 62202306)
  • HKPolyU (ZGGG)
Topics
  • Physical Sciences › Computer Science › Information Systems › Software Engineering Research
  • Physical Sciences › Computer Science › Software › Software Testing and Debugging Techniques
  • Physical Sciences › Computer Science › Computer Science Applications › Teaching and Learning Programming
Keywords
large language models, automatic code generation, code quality assessment, program correctness, code complexity, software vulnerabilities, Common Weakness Enumeration, non-determinism, programming languages

About these checks

Registry, retraction, Cites and statistics results are computed, not judged, with one exception: a printed reference that no index lists is read once by a model before it counts as a citation error. Claims are extracted by a model and kept only when their quote appears verbatim in the text; each cited source is then checked, with a model’s help, for whether it says what the claim relies on. Those verdicts can be wrong — read the claim’s quote and the cited source before relying on one.

Statistics and arithmetic are recomputed, not judged.

Confidence bands are shown only for fields calibrated on our annotated test set. None is calibrated yet, so no band is shown.

What counts as a claim ›How we measure confidence ›How we check this ›

Are you an author, or do you see a problem with this page? Request a review