Skip to main content

A tool to analyze Django projects for unused components

Project description

Django Project Scrubber

A powerful tool to analyze Django projects for unused components, helping you keep your codebase clean and maintainable.

Features

  • Identifies potentially unused URLs (including namespaced URLs and Django built-in URLs)
  • Finds unused methods (coming soon)
  • Detects duplicate method implementations (coming soon)
  • Identifies unused templates (with improved include/extends detection and Django template analysis)
  • Supports partial templates (files starting with underscore)
  • Enhanced URL detection in templates (including href attributes and form actions)
  • Improved detection of templates used in class-based views and error handlers
  • Better handling of templates that use URLs (marking them as used)

Installation

pip install django-project-scrubber

Usage

To analyze a Django project, run:

django_scrubber /path/to/your/django/project

The tool will analyze your project and display a summary of findings, including:

  • Potentially unused URLs (excluding admin and auth URLs)
  • Unused methods (coming in future versions)
  • Duplicate method implementations (coming in future versions)
  • Unused templates (including analysis of includes, extends, and view usage)

Example Output

Django Project Analysis Summary
==============================

✅ No unused URLs found! All URLs are being used.

✅ No unused methods found! All methods are being used.

✅ No duplicate methods found! All methods are unique.

✅ No unused templates found! All templates are being used.

🎉 Great news! Your Django project is clean and well-maintained.
No unused components were found in your codebase.

How It Works

The Django Project Scrubber analyzes your Django project by:

  1. Scanning all URL patterns in your project
  2. Checking URL usage in templates and code (including namespaced URLs)
  3. Analyzing Django source code for built-in URL and template usage
  4. Analyzing template usage (includes, extends, and view rendering)
  5. Supporting partial templates (files starting with underscore)
  6. Detecting URLs in template attributes (href, form actions)
  7. Identifying templates used in class-based views and error handlers
  8. Marking templates that use URLs as used
  9. Filtering out common false positives (admin, auth, etc.)
  10. Providing a clear summary of potentially unused components

Requirements

  • Python 3.8 or higher
  • Django 3.0 or higher

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License

Author

HappyMinsker - GitHub

Project Status

This is version 0.1.6 with improved template and URL analysis functionality, including support for partial templates, enhanced URL detection in template attributes, and better handling of templates used in class-based views and error handlers. More features are planned for future releases.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_project_scrubber-0.1.6.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_project_scrubber-0.1.6-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file django_project_scrubber-0.1.6.tar.gz.

File metadata

  • Download URL: django_project_scrubber-0.1.6.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.7

File hashes

Hashes for django_project_scrubber-0.1.6.tar.gz
Algorithm Hash digest
SHA256 bba0c9d0a1942075076a5f8468f2a92ec4f2acce05519e9658af9c0f2886efb5
MD5 93096edb246dc38a70bf1cf28cd06dd4
BLAKE2b-256 214bef081a42668adc7423b34aad0cd0b95cc8071159c2f90c24f38fdefb19c6

See more details on using hashes here.

File details

Details for the file django_project_scrubber-0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for django_project_scrubber-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 15f3be7849ba70aea9c3a3d9b69f83112fe99ca634a30424db7e110567c3bab7
MD5 fce562a8be6a82b1f073aba5e785e583
BLAKE2b-256 7e9702bf2dcd86068dfa7f6633a2f24dd28d397d76c7be1b7133ff50f0cf312d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page