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

The DOI matches its Crossref record; 49 of the 49 references it cites were found in a registry or an index; none of the 27 sources its claims cite is checked for support yet.

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

Open access
Liu, Yue, Le-Cong, Thanh, Widyasari, Ratnadira, Tantithamthavorn, Chakkrit, Li, Li, Le, Xuan-Bach D., Lo, David·2024·ACM Transactions on Software Engineering and Methodology

Abstract

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.

Overview

AI snapshot

Written from the paper’s full text.

TL;DR

This paper empirically evaluates ChatGPT-generated solutions for 2,033 LeetCode tasks in Java and Python, finding that many correct programs still carry quality problems. It also tests whether feedback prompts can help ChatGPT repair those issues, with partial success.

Key findings

  • Of 4,066 generated programs, 2,756 passed all tests, 1,082 produced wrong outputs, and 177 had compilation or runtime errors. Overall pass@1 was 0.664 for Python and 0.691 for Java, with performance dropping on harder tasks and newer tasks.
  • Code style and maintainability issues were common: 1,930 of 4,066 programs (47%) had such issues, including 1,243 of 2,756 passing programs (45%). Wrong outputs were also frequent, affecting 1,082 programs (27%).
  • ChatGPT could partially self-repair issues, with reported fix rates from about 20% to 60%. Feedback containing static-analysis and runtime-error details helped more for style and maintainability, while simple feedback sometimes worked better for other issue types.
  • Iterative repair improved code quality over rounds, but new issues were sometimes introduced in the fixed versions.

Methods

  • The authors built a benchmark of 2,033 LeetCode tasks (501 easy, 1,064 medium, 468 hard) and prompted ChatGPT-March-23 with zero-shot prompts, temperature 0, one run per task, generating Java and Python code.
  • Correctness was measured with pass@1 against LeetCode test suites; static analysis used PMD and Checkstyle for Java, and Pylint and Flake8 for Python.
  • Issues were categorized through open card sorting on a sample of 154 tasks, then quantified. Repair experiments compared simple feedback against feedback augmented with static-analysis and runtime-error information, including iterative rounds on 402 tasks released after 2022.

Limitations

  • The paper states external-validity limits: the dataset comes only from LeetCode and covers only Java and Python, so findings may not generalize to other tasks, languages, or project types.
  • The paper states internal-validity concerns around possible bugs in the authors’ code and manual categorization bias, mitigated by public code, three annotators, and temperature 0.
  • The paper states construct-validity concerns about pass@1 relying on LeetCode test suites and prompt variability; it also notes possible data leakage or memorization for older tasks. Evident from the text: only one ChatGPT version and one generation per task were used, which limits claims about other models or repeated sampling.

Model-written summary. Check it against the paper before relying on it.

Integrity signals

Registry

Crossref · 10.1145/3643674

Cites

49 of 49 references verified0 citation errors · 0 not checkable

Statistics

Nothing to recompute.

Verification

Claims the paper makes

77 Own result · 25 Own interpretation · 21 Not checked yet · 9 No basis given · 6 Own method

Verify all 27 references — free account

Show all 73 claims

  • It may state two separate claims as one. 39
  • Probably not a substantial claim. 35
  • The quote only partly states this claim. 2
65 of 65
  • The paper relies on this without support.

    No prior study formally investigates the reliability and quality of ChatGPT-generated code.

    “there exists no study that formally investigates the reliability and quality of code generated by ChatGPT”
  • The paper relies on this without support.

    This work is the first formal study of the reliability and quality of ChatGPT-generated code.

    “we are the irst to formally study the reliability and quality of ChatGPT-generated code”
  • The paper relies on this without support.

    LeetCode's difficulty labels accurately reflect the difficulty of programming tasks.

    “501 classiied as easy, 1,064 as medium, and 468 as hard”
  • The paper relies on this without support.

    Code quality issues are the most important concern because a single quality issue can lead to monetary and reputation costs.

    “Code quality issues are the most important concern, as one quality issue (aka.software defect) could lead to monetary and reputation costs.”
  • The paper relies on this without support.

    ChatGPT is a probabilistic model that predicts subsequent tokens based on preceding ones.

    “These observations can be explained by the probabilistic nature of the ChatGPT model, which predicts subsequent tokens based on preceding ones.”
  • The paper relies on this without support.

    Python's dynamic typing system allows more flexibility in variable types but can lead to unexpected type-related issues at runtime.

    “This observation could be due to Python's dynamic typing system, which allows for more lexibility in variable types, but can also lead to unexpected type-related issues at runtime.”
  • The paper relies on this without support.

    The original LeetCode test suite is carefully designed and widely recognized.

    “In our experiments, we use the original test suite from LeetCode, which is carefully designed and widely recognized.”
  • The paper relies on this without support.

    GPT-3.5's pretraining knowledge cutoff occurred before the year 2022.

    “we only use the 402 new test examples from LeetCode that were published in the year 2022 (after GPT-3.5'spre-training knowledge cutof).”
  • The paper relies on this without support.

    ChatGPT can learn from user interactions and improve its outputs based on feedback.

    “Unlike traditional code generation tools, ChatGPT has the potential to learn from user interactions and reine its outputs based on the feedback it receives.”
9 of 9

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?

Self-check

Percentages, sums and reported differences re-computed from the paper’s own numbers.

Each contradiction between two passages listed here was confirmed by an independent check.

3 of 3

Citations

Cites

Research works printed but not linked: 9

  1. Amazon. 2023. Amazon CodeWhisperer. Retrieved from https://aws.amazon.com/codewhisperer/
  2. Tom Copeland. 2005. PMD applied. Vol. 10. Centennial Books San Francisco.
  3. Ian Cordasco and Tarek Ziade. 2010. Flake8: Your tool for style guide enforcement. Programa De Computador (2010).
  4. Shuzheng Gao, Xin-Cheng Wen, Cuiyun Gao, Wenxuan Wang, and Michael R. Lyu. 2023. Constructing effective in-context demonstration for code intelligence tasks: An empirical study. arXiv preprint arXiv:2304.07575 (2023). · arXiv
  5. LeetCode. 2023. 1093. Statistics from a Large Sample. Retrieved from https://leetcode.com/problems/statistics-from-a-large-sample/description/
  6. Carlini Nicholas, Ippolito Daphne, Jagielski Matthew, Lee Katherine, Tramer Florian, and Zhang Chiyuan. 2023. Quantifying memorization across neural language models. In 11th International Conference on Learning Representations. 70–80.
  7. Alec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, Ilya Sutskever, et al. 2019. Language models are unsupervised multitask learners. OpenAI Blog 1, 8 (2019), 9.
  8. SimilarWeb. 2023. ChatGPT’s Traffic Overview. Retrieved from https://www.similarweb.com/website/chat.openai.com
  9. Donna Spencer. 2009. Card Sorting: Designing Usable Categories. Rosenfeld Media.

Cited by

Sorted by citations

See all 152

Metadata

Authors
Liu, Y., Le-Cong, T., Widyasari, R., Tantithamthavorn, C., Li, L., Le, X.-B. D., & Lo, D.
Affiliations
  • Monash University (AU)
  • The University of Melbourne (AU)
  • Singapore Management University (SG)
  • Beihang University (CN)
Venue
ACM Transactions on Software Engineering and Methodology
Published
2024-06-04
Volume
33
Issue
5
Pages
1-26
ISSN
  • 1049-331X (ISSN-L)
  • 1557-7392
OpenAlex
W4391282616
Cited by
149
References
43
Citations by year
2026: 36 · 2025: 75 · 2024: 37
FWCI
55.65
Type
journal article
Language
en
Open access
Locations
  • ACM Transactions on Software Engineering and Methodology (publishedVersion)
  • arXiv (Cornell University) (submittedVersion)
  • Singapore Management University Institutional Knowledge (InK) (Singapore Management University) (submittedVersion, cc-by-nc-nd)
  • Adelaide Research & Scholarship (AR&S) (University of Adelaide) (submittedVersion)
  • arXiv (Cornell University)
Funders
  • National Research Foundation (NRF-NRFI08-2022-0002)
  • Australian Research Council’s Discovery Early Career Researcher Award (DE200100941)
  • Australian Government through the Australian Research Council’s Discovery Early Career Researcher Award (DE220101057)
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
ChatGPT, large language models, code generation, code quality, program correctness, static analysis, software maintainability, code style, self-healing, Java, Python, compilation errors, runtime errors, task difficulty

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.

A language model drew the claims from the paper on 2026-10-07, under version 3 of the claim definition (model deepseek-v4.1-flash, prompt extract-v3).

A second model labelled each claim on 2026-10-07 (model jev-1.13-20260917, definition revision gold-guideline-v0.2).

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