This is a tool developed to enable code smell detection in JavaScript (JS) based files. A user can submit a zipped folder or a file during conversation for evaluation for code smells. After this, they can interact with the chatbot regarding the generated report.
The underlying model is ChatGPT with system prompts developed for teaching assistants of a software engineering course.
The report is generated in markdown format.
Note : This tool requires you to have your own OpenAPI key.
Go to the folder smellmjsV1. Install the required packages using -
pip install -r requirements.txtIn the same folder, create a .env file containing your OpenAPI key. Save the key as :
OPENAI_API_KEY = <your_openapi_key>
Now, in the same folder, run the program smellmjs.py
python3 smellmjs.pyThis should run the program as intended in default mode. Intially it will ask to choose a model. It is recommended to go for the first choice -
1. gpt-4o - (Context window = 128000 Tokens)
Following this it will ask you to create a folder to save the generated output reports. Enter the path where you want to create the folder.
Then the main menu options will show up.
Option 1 allows the user to submit a path to the zipped folder for evaluation and report generation.
Option 2 allows the user to converse with the chatbot. It also enables the user to upload a single file.
Option 3 allows the user to refresh context so that they can converse with the chatbot with the conversation reset to intial settings.
Option 4 allows the user to switch models which also switches context.
Option 5 allows the user to exit the program.
Note : There is an experimental feature to generate report according to each code smell. To enable it, when you write the command to start the program, add the argument - each_code_smell
python3 smellmjs.py each_code_smell| Bloaters | Object-Orientation Abusers | Change Preventers | Dispensables | Couplers |
|---|---|---|---|---|
| Long Method | Switch Statements | Divergent Change | Lazy Class | Feature Envy |
| Primitive Obsession | Temporary Field | Shotgun Surgery | Data Class | Inappropriate Intimacy |
| Long Parameter List | Refused Bequest | Parallel Inheritance Hierarchies | Duplicate Code | Message Chains |
| Data Clumps | Alternative Classes with Different Interfaces | Speculative Generality | Middle Man | |
| Large Class | Dead Code | Incomplete Library Class | ||
| Comments | ||||
To try out the program, you can use the zipped folder badcode.zip or the file trialcodepass.js as inputs to the program depending on the option.