Skip to content

This project uses Python AST module to parse code structure and applies rule based decision making to evaluate code quality and detect bad practices.

Notifications You must be signed in to change notification settings

Yash-200608/AI_Code_Reviewer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿค– AI Code Reviewer (Python + AST)

A lightweight AI-inspired Code Reviewer built using Python and Streamlit that analyzes Python code for syntax errors, structural issues, and basic code quality metrics.

This project demonstrates static code analysis using Pythonโ€™s AST module and a rule-based scoring system.


๐Ÿš€ Features

  • โœ… Syntax error detection using ast.parse()
  • ๐Ÿ“ Code length analysis
  • ๐Ÿ“ Comment presence detection
  • ๐Ÿ”ค Variable naming analysis
  • ๐Ÿ“Š Dynamic scoring system
  • ๐Ÿ† Grade classification (Outstanding, Excellent, Good, etc.)
  • ๐ŸŒ Web interface built with Streamlit
  • ๐Ÿง  Modular project structure (analyzer + scorer separation)

๐Ÿง  How It Works

  1. User pastes Python code into the web interface.

  2. The analyzer.py module:

    • Parses code into an Abstract Syntax Tree (AST)
    • Detects syntax issues
    • Applies rule-based checks
  3. The scorer.py module:

    • Calculates quality score
    • Assigns grade
    • Generates feedback
  4. Results are displayed via Streamlit UI.


๐Ÿ›  Tech Stack

  • Python 3.x
  • Streamlit
  • AST (Abstract Syntax Tree module)
  • Regular Expressions (re)

๐Ÿ“‚ Project Structure

AI_Code_Reviewer/
โ”‚
โ”œโ”€โ”€ app.py
โ”œโ”€โ”€ analyzer.py
โ”œโ”€โ”€ scorer.py
โ”œโ”€โ”€ requirements.txt
โ””โ”€โ”€ venv/

โš™๏ธ Installation & Setup

1๏ธโƒฃ Clone the Repository

git clone https://github.com/Yash-200608/AI_Code_Reviewer
cd AI_Code_Reviewer

2๏ธโƒฃ Create Virtual Environment

python -m venv venv

3๏ธโƒฃ Activate Virtual Environment

Windows:

venv\Scripts\activate

Mac/Linux:

source venv/bin/activate

4๏ธโƒฃ Install Dependencies

pip install -r requirements.txt

5๏ธโƒฃ Run the Application

streamlit run app.py

Then open:

http://localhost:8501

๐Ÿ“Š Scoring Logic

  • Base Score: 100

  • Syntax Error: โˆ’10

  • Each detected issue: โˆ’3

  • Grades:

    • 95+ โ†’ Outstanding
    • 85+ โ†’ Excellent
    • 75+ โ†’ Good
    • 60+ โ†’ Average
    • Below 60 โ†’ Needs Improvement

๐ŸŽฏ Learning Outcomes

  • Understanding Python AST
  • Static code analysis fundamentals
  • Rule-based evaluation systems
  • Web app development using Streamlit
  • Debugging and modular project design
  • Virtual environment management

๐Ÿ”ฎ Future Improvements

  • AST-based complexity analysis
  • Cyclomatic complexity calculation
  • Recursion detection
  • GitHub repository analyzer
  • Machine Learning-based code scoring
  • Advanced UI styling

๐Ÿ‘จโ€๐Ÿ’ป Author

Developed by Yash as a B.Tech CSE (AIML) project to explore static code analysis and AI-inspired evaluation systems.

About

This project uses Python AST module to parse code structure and applies rule based decision making to evaluate code quality and detect bad practices.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages