Skip to content

The CodeQuality4DevGPT project aims to enhance ChatGPT's code quality using linters for Python, Java, & JavaScript, addressing issues from style to logical errors, and improving code efficiency.

License

Notifications You must be signed in to change notification settings

ahabegger/CodeQuality4DevGPT

Repository files navigation

CodeQuality4DevGPT

CodeQuality4DevGPT is a project focused on identifying quality issues in code generated by ChatGPT. By utilizing various linters, this project aims to analyze the code for errors ranging from minor stylistic issues to more critical logical and efficiency problems. The analyzed code is sourced from the DevGPT database and GitHub API.

Study Overview

Study: Beyond Generation: A Comparative Analysis of Quality Issues in ChatGPT-Produced Code Across Programming Languages

Raw Data: Data

Classified Data: Data

This study aims to evaluate the quality of code generated by ChatGPT across multiple programming languages including Python, Java, and JavaScript. By employing a set of robust linters—Pylint for Python, PMD for Java, and JSHint for JavaScript—the research scrutinizes common issues such as stylistic inconsistencies, logical errors, and severe programming flaws within the code samples sourced from the DevGPT database. This analysis not only identifies prevalent problems but also assesses the strengths and weaknesses of each linter in detecting these issues, offering a comparative insight that informs on potential areas for enhancement in AI-generated code.

Research Question 1: How does ChatGPT Perform Across Programming Languages?

Comparison of the Error Types of Python, Java, and Javascript

Further, the findings contribute significantly to understanding the limitations and capabilities of AI in coding, which is crucial for integrating AI tools more effectively into software development workflows. By highlighting common pitfalls in AI-generated code and providing empirically driven recommendations for best practices, the study aims to improve the reliability and productivity of AI as a development tool. This research aligns with the objectives of the MSR 2024 Mining Challenge, thereby advancing the broader agenda of enhancing code quality in the era of AI-assisted programming.

Research Question 2: What are the Differences Between AI-Generated and Human-Written Code?

Comparison of the Error Types and Error Frequency of Python

Comparison of the Error Types and Error Frequency of Java

Comparison of the Error Types and Error Frequency of JavaScript

Prerequisites

Before you begin, ensure you have the following installed:

  • Python 3.7: Download here
  • Pip Env
  • Java 8 or above

Installation

  1. Clone the repository:

    git clone https://github.com/ahabegger/CodeQuality4DevGPT.git
  2. Set up Python packages: Navigate to the CodeQuality4DevGPT folder and install the required packages:

    pip install -r requirements.txt
  3. Set up Linters:

    • JSHint:
      • Set up an NPM environment and install JSHint using the instructions here.
      npm install -g jshint
      npm fund
    • PMD:
      • Download PMD from PMD GitHub and follow the installation guide here.
  4. Setting Up GitHub API: Within the CodeQuality4DevGPT folder, create a token.txt file and store your GitHub token:

    touch token.txt
    echo "{GITHUB Token}" > token.txt

Usage

Navigate to the CodeQuality4DevGPT folder and run the following commands to execute the programs:

python ChatGPTCode
python HumanCode

Output files will be located in the Output folder.

Classifying Errors

Follow the classification instructions provided in Appendix A of the Study

Linters

Contributing

Contributions to improve CodeQuality4DevGPT are welcome. Please ensure to update tests as appropriate.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Additional Resources

About

The CodeQuality4DevGPT project aims to enhance ChatGPT's code quality using linters for Python, Java, & JavaScript, addressing issues from style to logical errors, and improving code efficiency.

Topics

Resources

License

Stars

Watchers

Forks

Languages