piranha open source tool to delete obsolete code

Uber has open-sourced a tool named Piranha that automatically deletes unused and obsolete code from app codebases.

The ride-sharing company says Piranha will help developers by automating the task of code removal, which consumes a lot of time when done manually.

Piranha: Automatic Removal Of Stale Flags

As the blog post explains, Uber uses feature flags for Android and iOS mobile app development. Feature flags are used to customize mobile app execution — it means serving different features to different sets of users.

Piranha_automated code removal

Using feature flags, companies like Uber can localize the user experience in different regions they operate. It helps Uber and other companies gradually roll-out features to users across the world, and experiment with different variations of the same functionality.

Now, these feature flags either turn into a successfully implemented feature or simply become an unsuccessful attempt. In either case, the feature flag is not relevant anymore and turns into a stale feature flag.

That is precisely where developers need Piranha. This open-source tool can automatically delete these feature flags that are no longer needed, along with their corresponding code. Obsolete code like stale feature flags not only creates clutter in the codebase and increase its complexity but also interferes with other flags or lead to bugs at times.

Piranha_stale flag remover

The flag management system periodically sends a list of potentially stale flags to Piranha, which generates a diff and sends it to the original flag author. The author can then determine whether to land the diff.

Removing technical debt from code

Piranha currently works for code written in Objective-C, Swift, and Java. Now that it has been open-sourced, other open-source contributors could build upon the existing version and make it available for other programming languages as well.

Uber says it as used Piranha to remove around two thousand stale feature flags and their related code. The company recommends using Piranha in applications that use feature flags extensively and implement specific APIs to control their behavior.

To read more about Piranha, you can refer to the Uber blog and get it on GitHub.

SHARE
Avatar
An Editor and a Tech Journalist with a software development background. I am a big fan of technology and memes. At Fossbytes, I cover all aspects of tech but my specific area of interest is Programming and Development. Drop an email if you have any software/hardware/research to share or tech-related queries!