Uber announced Piranha, a tool that automatically removes obsolete and unnecessary code from projects. Originally created to help developers remove unnecessary code from the company’s apps, Piranha is now available open-source.

Specifically, the tool cleans up expired feature flags, which are software components for continuous delivery (CD). Feature flags, also known as feature toggles, function as a kind of on/off button for code. Uber uses them to help test new features in apps before they are released for general availability. Feature flags also provide a way to customise features for different users, or to use them as a code kill switch, allowing developers to remotely disable a poorly functioning part of an application.

Feature flags, however, also add complexity to an application’s code and have had to be removed manually as soon as they no longer serve their purpose. Piranha can largely automate the removal of unnecessary feature flags. The tool finds all feature flags in an application that have not been modified for a certain period of time, checks if they are in active use, and deletes all associated code if they are not. After that, the removal is submitted to the developer for verification.

Automating the removal of old code in applications not only frees up time for developers, but potentially accelerates security by reducing the workload of an attack surface. Piranha is available on GitHub. The tool currently supports the Objective-C, Swift, and Java programming languages.