dead simple python dead code detection
Project description
dead
dead simple python dead code detection
installation
pip install dead
cli
Consult the help for the latest usage:
$ dead --help
usage: dead [-h] [--files FILES] [--exclude EXCLUDE] [--tests TESTS]
optional arguments:
-h, --help show this help message and exit
--files FILES regex for file inclusion, default: ''
--exclude EXCLUDE regex for file exclusion, default '^$'
--tests TESTS regex to mark files as tests, default
'(^|/)(tests?|testing)/'
run the dead
utility from the root of a git repository.
as a pre-commit hook
See pre-commit for instructions
Sample .pre-commit-config.yaml
:
- repo: https://github.com/asottile/dead
rev: v0.0.8
hooks:
- id: dead
how it works
- find all files in a repository using
git ls-files
and filtering:- only include files matched by the
--files
regex - exclude files matched by the
--exclude
regex - only include files identified as
python
byidentify
- classify test files by the
--tests
regex
- only include files matched by the
- ast parse each file
- search for definitions and references
- report things which do not have references
false positives
I wrote this in ~15 minutes on an airplane, it's far from perfect but often finds things. Here's a few things it's not good at:
- functions which implement an interface are often marked as unused
- metaclass magic is often marked as unused (enums, model classes, etc.)
suppressing dead
The # dead: disable
comment will tell dead
to ignore
any line which has reportedly dead code.
is this project dead?
maybe.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dead-0.0.8.tar.gz
(6.0 kB
view details)
Built Distribution
File details
Details for the file dead-0.0.8.tar.gz
.
File metadata
- Download URL: dead-0.0.8.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee0eca5bc46953f9b2cca7245f1daa140385d6a06ac7abf15fdb349050a4eab7 |
|
MD5 | 474188a38a6c2303b0a60e6ffd7d3c32 |
|
BLAKE2b-256 | 141edec50602239276de0ccf51211c9e3d2763462027c33603cdc72147c94a0f |
File details
Details for the file dead-0.0.8-py2.py3-none-any.whl
.
File metadata
- Download URL: dead-0.0.8-py2.py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 206656067b05abf2f8e697ceead3e5e6ac1ad7f1de971354f71282566831d4d5 |
|
MD5 | 9424b4498da7d76b330384f19b795144 |
|
BLAKE2b-256 | 6616e9664b61e4c9f2ec18d3cd4de2b58fbd42be14657909a9dd8baf6caa7e74 |