Uber Open Sources Piranha Stale Code Remover
Wednesday, 25 March 2020

Uber has released an open source version of Piranha, a tool that scans source code to delete code related to stale, or obsolete, feature flags.

Piranha is run at Uber in an ongoing pipeline for its Android and iOS codebases and has been used to remove around two thousand stale feature flags and their related code. Uber says it has led to a cleaner, safer, more performant, and more maintainable code base.

piranha

Piranha is designed to overcome the problems caused by gradual rollouts of apps with new features. The Uber team uses feature flags to enable this, along with experimenting with new features. In a few cases, even after the purpose of the flag is accomplished, the code pertaining to the feature flag is not removed, which Uber refers to as a stale flag. Leaving the code in the app means its unnecessarily more complex than it needs to be. The Uber team says it also means the flags can interfere with other experimental flags in ways such as nesting under a flag that is always false.

Piranha is a tool to automatically refactor code related to stale flags. At a higher level, the input to the tool is the name of the flag and the expected behavior, after specifying a list of APIs related to flags in a properties file. Piranha will use these inputs to automatically refactor the code according to the expected behavior.

The tool automatically generates differential revisions - diffs - to delete code corresponding to stale feature flags. Piranha takes as input the name of the flag, expected treatment behavior, and the name of the flag’s author. It analyzes the abstract syntax trees (ASTs) of the program to generate refactorings which are packaged into a diff. The diff is assigned to the author of the flag for further inspection. The author can then choose to commit the changes to the master, performing any additional refactorings before landing it.

The current repository on GitHub contains three independent versions of Piranha, one for each of the three supported languages: Objective-C, Swift, and Java.

piranha

More Information

Pirhana On GitHub

Related Articles

Scientist Lets You Refactor Live

Refactoring to Kotlin Codelab

Java Dependency Analysis and Modularization

 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

Banner


GitHub Announces Free Copilot
19/12/2024

GitHub has launched GitHub Copilot Free, a free version of Copilot that provides limited access to selected features of Copilot and is automatically integrated into VS Code. The free tier is aimed at  [ ... ]



Windows 11 Adoption Takes A Downturn
11/12/2024

With Windows 10 End of Life only ten months away, Microsoft is stepping up its campaign to get Windows users to upgrade to Windows 11. But while Windows 11 had been gaining users at a steady rate at t [ ... ]


More News

{laodposition comment}

Last Updated ( Wednesday, 25 March 2020 )