code_smell_detector / README.md
NajmiHassan1's picture
Update README.md
c8d4b31 verified

A newer version of the Streamlit SDK is available: 1.56.0

Upgrade
metadata
title: Code Smell Detector
emoji: ๐Ÿ˜ป
colorFrom: yellow
colorTo: yellow
sdk: streamlit
sdk_version: 1.44.1
app_file: app.py
pinned: false

Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference

๐Ÿ Python Code Smell Detector

A user-friendly web application for detecting code quality issues in Python codebases. Analyze your Python files to find potential problems before they lead to maintenance headaches.

image Preview Image 1

image Preview Image 2

๐Ÿ“‹ Introduction

The Python Code Smell Detector is an interactive tool that helps developers identify potential issues in their Python code. It automatically detects common "code smells" that might indicate deeper problems in your codebase.

What are Code Smells?

Code smells are patterns in code that suggest potential design or implementation problems. They're not bugs, but they might lead to bugs or make your code harder to maintain in the future.

Why Use This Tool?

  • Improve Code Quality: Identify problematic patterns early
  • Reduce Technical Debt: Fix issues before they compound
  • Enhance Maintainability: Make your codebase easier to work with
  • Learn Better Practices: Understand common pitfalls to avoid

Features

๐Ÿ” Code Smell Detection

The tool currently detects the following code smells:

  • Long Functions: Functions that exceed a configurable line limit
  • Too Many Parameters: Functions with excessive parameters
  • Duplicate Code: Repeated blocks of code that could be refactored

๐Ÿ“Š Analysis Report

  • Visual indicators of detected issues
  • Detailed explanation of each code smell
  • Downloadable markdown report for sharing with your team

๐Ÿš€ Setup

Prerequisites

  • Python 3.6+
  • pip (Python package installer)

Here's the markdown code for your installation instructions:

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/code-smell-detector.git
cd code-smell-detector
  1. Create a virtual environment (optional but recommended):
python -m venv venv
source venv/bin/activate  # On Windows, use: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt

Running Locally

Start the Streamlit server:

streamlit run app.py

The application will open in your default web browser at http://localhost:8501.

๐Ÿ”ง How to Use

  1. Upload Your Python File:

    • Click the "Choose a Python file" button
    • Select any .py file from your computer
  2. Configure Detection Settings (in the sidebar):

    • Adjust the block size for duplicate detection
    • Set the maximum function length threshold
    • Configure the maximum parameter count
  3. Review Results:

    • The tool displays detected issues categorized by type
    • Expand duplicate code blocks to see the actual duplicated code
  4. Download Report:

    • Click "Generate Download Report" in the sidebar
    • Save the markdown file for future reference or team sharing

๐Ÿ”ฎ Upcoming Features

Automatic Refactoring

I will be working on a new feature that will not only detect issues but also suggest or automatically implement refactoring solutions:

  • Extract Method transformations for long functions
  • Parameter Object creation for functions with too many parameters
  • Extract Duplicate code into shared functions
  • Preview Changes before applying them
  • Apply Refactoring directly to your code with one click

Made with โค๏ธ by [Najmi Hassan]