A CLI tool for static code analysis and fixing using Gemini AI
Project description
SDLC-Automation
Graduation project - CLI Backend for Static Issue Analysis and Fixing
Overview
This project provides a command-line interface (CLI) tool called ejd that helps developers analyze and fix static issues in their code using configurable rule sets and LLM integration.
Installation
pip install -e .
Usage
Basic Command Structure
ejd -si fix "path/to/your/file.py"
Interactive Workflow
- Run the command with your source file path
- The tool will prompt you to enter a rule set file path
- Both files are validated and loaded into variables
- The data is prepared for LLM processing
Example Usage
# Fix static issues in a Python file
ejd -si fix "src/main.py"
# The tool will then prompt:
# 📋 Please enter the path to the rule set file: rules/python_rules.txt
Features
- ✅ File validation for both source and rule set files
- 🔧 Interactive rule set path input with validation
- 💾 Automatic loading of file contents into variables
- 🤖 Ready-to-use data structure for LLM integration
- � Non-destructive workflow - creates fixed files while preserving originals
- �🚀 Extensible architecture for future enhancements
Gemini Flash 2.5 Integration
This tool is integrated with Google's Gemini Flash 2.5 model for intelligent static code analysis and automated fixing.
Setup
-
Install dependencies (automatically handled during installation):
pip install -e .
-
Get your Gemini API key:
- Visit: https://aistudio.google.com/app/apikey
- Sign in with your Google account
- Create a new API key
- Copy the generated key
-
Configure the API key (choose one method):
Option A: Using the setup script (Recommended)
python setup_gemini.pyOption B: Manual configuration
# Create a .env file in the project root echo "GOOGLE_API_KEY=your_actual_api_key_here" > .env
Option C: Environment variable
# Windows PowerShell $env:GOOGLE_API_KEY="your_actual_api_key_here" # Windows CMD set GOOGLE_API_KEY=your_actual_api_key_here
How It Works
- Analysis: Gemini analyzes your source code against the provided rules
- Issue Detection: Identifies code quality, security, and performance issues
- Automated Fixing: Generates corrected code that addresses all issues
- Interactive Review: Shows you what issues were found and asks for confirmation before applying fixes
Example Analysis Results
The tool provides detailed analysis including:
- Issues Found: Line-by-line breakdown of problems
- Issue Types: Code quality, security vulnerabilities, performance issues
- Rule Violations: Which specific rules were violated
- Fixed Code: Complete corrected version of your code
- Best Practice Suggestions: Additional recommendations for improvement
- Markdown Report: Comprehensive analysis saved as a formatted markdown file
Markdown Report Features
Each analysis generates a detailed markdown report with:
- Structured Summary: Overview of all changes and improvements
- Issues Table: Organized table with line numbers, types, descriptions, and violated rules
- Complete Fixed Code: Full corrected source code in syntax-highlighted blocks
- Additional Suggestions: Best practice recommendations and improvement tips
- Timestamped Documentation: Generated date/time and source file information
Reports are automatically saved with timestamps (e.g., test_file_analysis_report_20251017_153045.md) for easy tracking and review.
Sample Output
🤖 Preparing to send data to Gemini Flash 2.5...
🔗 Testing connection to Gemini...
✅ Connected to Gemini successfully!
🎉 Analysis completed successfully!
📊 Issues found: 8
📄 Detailed markdown report saved to: test_file_analysis_report_20251017_153045.md
🐛 Issues identified:
1. Line 2: Unused import 'sys' - Remove unused imports
2. Line 15: SQL injection vulnerability - Use parameterized queries
3. Line 25: Missing type hints - Add type annotations for better code clarity
4. Line 30: Class name should be capitalized - Follow PEP 8 naming conventions
5. Line 45: Use list comprehension for better performance
� Preview of fixed code (first 200 characters):
# Fixed Python file - all static issues resolved
import os
import requests
from typing import List, Optional
import sqlite3
def calculate_total(items: List[int]) -> int:...
�💡 Would you like to create a fixed version? (y/n): y
✅ Fixed version created: test_file-fixed.py
📁 Original file preserved: test_file.py
📝 Summary: Fixed 8 issues including security vulnerabilities and code quality improvements
💡 Additional suggestions:
1. Consider adding docstrings to all functions and classes
2. Use more descriptive variable names where possible
3. Add error handling for file operations and user inputs
File Structure
ejad/
├── __init__.py
├── cli.py # Main CLI entry point
└── static_issue.py # Static issue fixing logic
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ejd-0.1.2.tar.gz.
File metadata
- Download URL: ejd-0.1.2.tar.gz
- Upload date:
- Size: 13.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ceb1d9da23dc15c0ff57a76be4f9553c775440634335be880f945acaf543c7c
|
|
| MD5 |
02574f573637ba044d97a4073deabf90
|
|
| BLAKE2b-256 |
f95be9896bf803208b6bff808b6d8960e74d734d913cd34e416eeda1b96fe8f5
|
File details
Details for the file ejd-0.1.2-py3-none-any.whl.
File metadata
- Download URL: ejd-0.1.2-py3-none-any.whl
- Upload date:
- Size: 12.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2e5b6177d3a6c1fcd8da7a9710600d1696fcaf00264372ec62f052fcd73da08
|
|
| MD5 |
91213797d7753bee608c105870cadc77
|
|
| BLAKE2b-256 |
3da72fc773b1625db9bc7c84c38614515822aaeee399bcece807e023277ba49c
|