Reducing dead code ratio of your project with vulture

Rahul Jha (~RJ722)


79

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.
  • VultureBear: Integration with coala - a static code analysis tool.
  • Integration with automatic analysis tools like GitMate, etc. for automatic code-reviews with native support for Github and Gitlab.

Prerequisites:

  • python (any version would do)
  • pip

Having coala installed will be a plus.

Content URLs:

Speaker Info:

Rahul Jha

He is currently pursuing B.Tech. (ECE) and has been developing software for 3 years now. He is an Open source enthusiast and as part of his GSoC project, he developed the vulture API for easy integration with coala.

Speaker Links:

You may find more about Rahul here:

The best way to contact him is through e-mail: rahul722j@gmail.com, rahul@rj722.tech

Section: Infrastructure
Type: Talks
Target Audience: Beginner
Last Updated: