This project is designed to detect common code smells such as Long Methods, God Classes, Long Parameter Lists, and Large Classes. It uses a Flask backend to provide APIs for code analysis and a React frontend for a user-friendly interface.
This tool identifies code smells in software projects. The backend is implemented using Flask and provides APIs for analyzing code. The frontend, built with React, interacts with these APIs to display results in an intuitive manner.
The four code smells addressed are:
- Long Methods - Functions that are excessively long.
- God Class - Classes that handle too many responsibilities.
- Long Parameter List - Functions with too many parameters.
- Large Class - Classes with too many methods and attributes.
The backend processes input code, detects these issues, and returns results via API endpoints. The frontend visualizes the findings for users.
Backend (Flask):
- Flask (Python web framework)
- Flask-CORS (for cross-origin requests)
- AST (Abstract Syntax Tree for Python code analysis)
- JSON (for storing analysis results)
Frontend (React):
- React (UI framework)
- Fetch API (for API communication)
- React Toastify (for notifications)
- CSS (for styling)
Follow these steps to set up and run the project locally:
Ensure you have the following installed:
- Python (3.8 or above)
- Node.js and npm
- Flask
Navigate to the backend directory:
cd backendInstall the required Python packages:
pip install flask flask-corsRun the Flask server:
python main.pyThe API will be available at http://127.0.0.1:5000.
Navigate to the frontend directory:
cd frontendThe frontend will be available at http://localhost:3000.
API Endpoints Below is the endpoint exposed by the Flask backend:
Method Endpoint Description POST /analyze-folder Analyzes Python code for code smells
- Start the Flask backend server.
- Start the React frontend application.
- Enter the folder path containing your Python code into the input box.
- Click on the Analyze button to start the analysis.
- View the detected code smells displayed in a structured format.
- Results will also be saved in the backend/analysis_results.json file
Below is the endpoint exposed by the Flask backend:
| Method | Endpoint | Description |
|---|---|---|
| POST | /analyze-folder | Analyzes Python code for code smells |
For any questions or suggestions, contact:
-Name: Muhammad Ahmad -Email: ahmadsaeed3220@gmail.com