Scavenge Dead Python bits with Vulture

Rahul Jha (~RJ722)


27

Votes

Description:

Maintaining a high level of code quality is important for any serious project. One aspect of this is ensuring that all code is actually used. There are many reasons for dead code ending up in a project. The most common is refactoring, but another is misspellings, which are only detected at runtime for dynamic languages. Finding and removing dead code allows to keep the code base clean and reduces bugs.

This talk is focussed on how we can use Vulture to find dead code. It helps you find unused code in Python programs and it is useful for cleaning up and finding errors in large code bases. If you run Vulture on both your library and test suite you can find untested code. Due to Python's dynamic nature, static code analyzers like Vulture are likely to miss some dead code. Also, code that is only called implicitly may be reported as unused. Nonetheless, Vulture can be a very helpful tool for higher code quality.

One part of this talk is to discuss how to automate testing for dead code with Vulture. There are quite a few options available:

  • Adding vulture to your continuous integration testing.
  • A script using the Vulture API for custom tests.
  • Identifying false positives and creating whitelists
  • VultureBear: Integration with coala - a static code analysis tool.

This talk is a revised version of a similar talk given at PyCon India 2017 (by the same speaker).

Prerequisites:

  • python and pip installed

Optional requirements:

  • coala
  • coala-bears

Content URLs:

The slides accompanying the talk, along with all the examples may be found at RJ722/reducing-dead-code. Other useful links:

Speaker Info:

Rahul Jha

He is currently pursuing B.Tech. (ECE) from Zakir Husain College of Engg. & Technology, Aligarh Muslim University. He develops free and open source software. His key contributions in the Vulture community include the vulture API, and the whitelisting scripts. Apart from computers, he likes playing with Robot Cars and editing Wikipedia pages.

Speaker Links:

You may find more about Rahul here:

You may contact him through:

  • e-mail: rahul722j@gmail.com
  • IRC: #vulture on freenode (nick: RJ722)

Id: 974
Section: Developer tools and Automation
Type: Talks
Target Audience: Intermediate
Last Updated: