๐Ÿ‘ป Sleepy Code

Python License

Find unused functions and methods in your PHP and Python codebases with style!

โœจ Features

  • ๐Ÿ” Detects unused functions, methods and static attributes
  • ๐ŸŽฏ Smart detection of interface implementations
  • ๐Ÿšซ Excludes route-annotated methods in PHP
  • ๐Ÿ“Š Interactive HTML report with filtering capabilities
  • ๐Ÿ”„ Multi-processing for fast analysis
  • ๐Ÿ Supports both PHP and Python codebases

๐ŸŽฏ TODO

  • Add support for TS
  • Detect unused classes (make them displayed in a new tab in the report)
  • Detect unused variables and imports

๐Ÿš€ Getting Started

Setup Virtual Environment & requirements

python -m venv venv --without-pip
source venv/bin/activate  # On Windows use: venv\Scripts\activate
pip install -r requirements.txt

๐Ÿ’ป Usage Examples

Analyze PHP codebase:

python deadcode.py /path/to/php/project --language php

Analyze Python codebase with result limit:

python deadcode.py /path/to/python/project --language python --limit 50

List all functions sorted by line count:

python deadcode.py /path/to/project --language php --list-functions

๐Ÿงช Testing

Run the test suite:

python -m unittest tests/test_python_analyzer.py

๐Ÿ“Š Reports

The tool generates an interactive HTML report:

Sort by name, lines, or usage count Toggle visibility of potential false positives Search and filter results Paginated results for easy navigation

Reports are generated as:

  • code_analysis_php.html for PHP analysis

  • code_analysis_python.html for Python analysis

  • ๐ŸŽจ Report Colors

  • ๐Ÿ”ด Red: Unused functions

  • ๐ŸŸ  Orange: Potential false positives

  • ๐ŸŸฃ Purple: Static attributes