Skip to content

Latest commit

Β 

History

History
81 lines (64 loc) Β· 2.5 KB

File metadata and controls

81 lines (64 loc) Β· 2.5 KB

code-refactor-tool

🐍 Python Code Refactor Tool

A web-based tool that automatically analyzes and refactors Python code using AST parsing and intelligent algorithms. Perfect for improving code quality and learning best practices.

🌐 Live Demo

Try it now: https://code-refactor-tool-production.up.railway.app

Or: https://code-refactor-tool.onrender.com

✨ Features

  • πŸ” AST-Based Analysis - Deep code analysis using Python's Abstract Syntax Trees
  • πŸ”€ Smart Variable Renaming - Automatically renames unclear single-letter variables
  • πŸ”„ Conditional Simplification - Extracts complex conditionals into readable variables
  • πŸ“ Duplicate Code Detection - Identifies and highlights repeated code patterns
  • 🎨 Beautiful Web Interface - Modern, responsive UI with syntax highlighting
  • ⚑ Real-time Processing - Instant refactoring results
  • πŸ“Š Code Quality Suggestions - Actionable improvement recommendations

πŸ› οΈ Tech Stack

  • Backend: Python, FastAPI, AST parsing
  • Frontend: HTML5, CSS3, JavaScript, Prism.js
  • Deployment: Railway, Uvicorn
  • Analysis: AST, astor, custom refactoring algorithms

πŸš€ Quick Start

Local Development

  1. Clone the repository

    git clone https://github.com/yourusername/code-refactor-tool.git
    cd code-refactor-tool
  2. Install dependencies

    pip install -r requirements.txt
  3. Run the application

    python run.py
  4. Open your browser Navigate to http://localhost:8000

Using Docker

# Build and run with Docker
docker build -t code-refactor-tool .
docker run -p 8000:8000 code-refactor-tool

πŸ“– Usage

Web Interface

Paste your Python code in the left editor Select refactoring options: βœ… Rename Unclear Variables βœ… Extract Duplicate Code βœ… Simplify Complex Conditionals βœ… Extract Methods βœ… Remove Dead Code

Click "Refactor Code" or press Ctrl+Enter View results in the refactored code panel Check suggestions for further improvements

Keyboard Shortcuts

Ctrl+Enter - Refactor code Ctrl+/ - Focus code editor Esc - Clear code editor

Sample Codes

The tool includes several sample codes to test: Complex Function - Long functions with multiple responsibilities Nested Conditionals - Deeply nested if-else statements Duplicate Code - Repeated logic across functions Messy Variables - Poorly named single-letter variables