Using ChatGPT for Static Code Analysis

Using ChatGPT for Static Code Analysis

Now that I have given you an overview of how we are applying ChatGPT for static code analysis, let me show you how I am using ChatGPT to analyze my students’ programming assignments. I use ChatGPT to assess and mark their assignments in a systematic way.

To begin, I open my browser to chat.openai.com and create a version of ChatGPT that uses the default settings. I avoid using the Advanced Data analysis portion as it has some bugs when parsing Java code. Instead, I switch over to my Emacs editor, which I have been using for about 40 years and find very effective.

I then show ChatGPT the scripts I am writing for use with it. For example, I have a script for a class called the ForkJoinCrawler. This class uses the Java Fork/Join framework to write a web crawler that recursively visits links and downloads images. I want to assess my students’ code based on their frequently made mistakes.

I provide ChatGPT with instructions to read the Java ForkJoinCrawler class and parse the Java code using its most advanced method. I also ask it to identify the class constructor and methods. By doing this, ChatGPT can accurately analyze the code and provide detailed responses to my questions.

I then give ChatGPT a list of questions based on my review of my students’ solutions. Some questions focus on what the code should not do, such as calling certain methods or using specific syntax. Other questions focus on what the code should do, such as using certain methods or following specific coding practices.

ChatGPT goes through the code line by line and provides summaries of what it is doing before answering the specific questions. It checks for errors such as creating a new ForkJoinPool, calling the shutdown method, or using try-catch blocks. It also checks for correct usage of methods and syntax, such as calling the common pool and using the correct syntax for incrementing variables.

Overall, ChatGPT proves to be a powerful tool for static code analysis. It helps me analyze my students’ code more effectively and provides consistent and detailed feedback. By using ChatGPT in conjunction with human graders, we can ensure more accurate and efficient code analysis for programming assignments.

In conclusion, ChatGPT is a valuable tool for static code analysis. It allows me to assess and mark my students’ programming assignments in a systematic and thorough manner. With its help, I can identify common mistakes and provide detailed feedback to improve their coding skills. By leveraging the power of generative augmented intelligence, we can enhance the code analysis process and ensure better learning outcomes for students.

Using ChatGPT4 as a Static Code Analysis Tool
Older post

Using ChatGPT4 as a Static Code Analysis Tool

Newer post

Using AI in Software Development: A Practical Guide

Using AI in Software Development: A Practical Guide