Skip to main content

Find dead code

Project description

vulture - Find dead code

vulture finds unused classes, functions and variables in your code. This helps you cleanup and find errors in your programs. If you run it on both your library and test suite you can find untested code.

Due to Python’s dynamic nature it is impossible to find all dead code for a static code analyzer like vulture, because it ignores scopes and scans only token names. Additionally, some dynamic items that are not explicitly called in the code may be incorrectly reported as dead code.

Features

  • Fast: Uses static code analysis

  • Lightweight: Only one module

  • Tested: Comes with a test suite and tests itself

  • Complements pyflakes and has the same output syntax

  • Supports Python 2.6, 2.7 and 3.x

Installation

$ pip install -U vulture

Usage

$ vulture --help

After you have found and deleted dead code, run vulture again, because it may discover more dead code. You can list false-positives (used code that is marked as unused) in a python module and add it to the list of scanned paths (see whitelist.py).

Similar programs

  • vulture can be used together with pyflakes

  • The coverage module can find unused code more reliably, but requires all branches of the code to actually be run.

Feedback

Your feedback is more than welcome. Write emails to jendrikseipp@web.de or post bugs and feature or pull requests on bitbucket:

https://bitbucket.org/jendrikseipp/vulture/issues

Source download

The source code is available on bitbucket. Fork away!

https://bitbucket.org/jendrikseipp/vulture

News

0.7 (2015-09-26)

  • Exit with exitcode 1 if path on commandline can’t be found.

  • Test vulture with vulture using a whitelist module for false positives.

  • Add tests that run vulture as a script.

  • Add “python setup.py test” command for running tests.

  • Add support for tox.

  • Raise test coverage to 100%.

  • Remove ez_setup.py.

0.6 (2014-09-06)

  • Ignore function names starting with “test_”.

  • Parse variable names in new format strings (e.g. “This is {x}”.format(x=”nice”)).

  • Only parse alphanumeric variable names in format strings and ignore types.

  • Abort with exit code 1 on syntax errors.

  • Support installation under Windows by using setuptools (thanks Reuben Fletcher-Costin).

0.5 (2014-05-09)

  • If dead code is found, exit with 1.

0.4.1 (2013-09-17)

  • Only warn if a path given on the command line cannot be found.

0.4 (2013-06-23)

  • Ignore unused variables starting with an underscore.

  • Show warning for syntax errors instead of aborting directly.

  • Print warning if a file cannot be found.

0.3 (2012-03-19)

  • Add support for python3

  • Report unused attributes

  • Find tuple assignments in comprehensions

  • Scan files given on the command line even if they don’t end with .py

0.2 (2012-03-18)

  • Only format nodes in verbose mode (gives 4x speedup).

0.1 (2012-03-17)

  • First release.

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

vulture-0.7.tar.gz (18.3 kB view details)

Uploaded Source

File details

Details for the file vulture-0.7.tar.gz.

File metadata

  • Download URL: vulture-0.7.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for vulture-0.7.tar.gz
Algorithm Hash digest
SHA256 beb4b57fba70f29d9bb24702051a95492c5775f93b4621261e15a7de74a838e3
MD5 b62598bc7773df83c9c8006b3ceba8bd
BLAKE2b-256 28ad9bf2c6eb4116ccc9883d8a7421d04d7423fbcdf94d84505c794a9577b99a

See more details on using hashes here.

Supported by

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