Codekvast

The Truly Dead Code Detector

View on GitHub

Codekvast - the Truly Dead Code Detector

Overview

Codekvast detects Truly Dead Code in Java-applications.

By Truly Dead Code we mean code that is in production, but has not been used by anyone for a certain period of time.

Codekvast works by attaching the Codekvast Collector to your application. The collector records the instant when methods belonging to any of your packages are invoked.

By default Codekvast tracks public and protected methods. Modern IDEs like IntelliJ IDEA can detect statically dead code, i.e., code which have package private or private visibility. They can never know what callers there are to public and protected methods though.

This is where Codekvast can help. Codekvast records when your methods are invoked in production.

The collector periodically sends the recorded data to the Codekvast Daemon, which combines the invocation data with an inventory of all methods in your application. (It's the methods that not have been invoked recently that constitutes Truly Dead Code, remember?)

The Codekvast Daemon is installed in the same host as your application, since it needs access to your application's binaries (jar files) to make the inventory.

The Codekvast Daemon periodically produces a zip file containing both the method inventory and the collected invocation data.

The zip files from all daemons should be transferred to a central Codekvast Warehouse, which aggregates the data, and makes it available to users in a web interface.

The Codekvast Daemon can be configured to automatically upload the zip files to the warehouse by means of SCP. If SCP is not an option, the zip files must be transferred manually somehow.

By using the Codekvast Warehouse, you can find out whether a certain method, class or package is safe to remove or not.

Codekvast collects the data. You use your domain knowledge to make informed decisions about what is truly dead code that safely could be deleted.

Performance

Codekvast Collector is extremely efficient. It adds approximately 15 nanoseconds to each method invocation. If this is unacceptable, you can exclude certain time critical packages from collection.

The collected data volumes are quite moderate. When tested on a telecom equipment vendors' fairly large network management application, the local database maintained by Codekvast Daemon occupies less than 200 MB disk space.

The zip file for that case weighs less than 3 MB.

License

Codekvast is released under the MIT license.