Uber Open-Sourced Piranha: A Tool To Automatically Delete Unused Codes
World’s most extensive transportation network company, Uber has been engaged in powerful developing techniques to provide a great user experience. Uber has been using feature flags to customise the mobile app execution, which serves various features to different sets of users. These feature flags help in localising the user’s experience in different operating regions as well as help to roll-out features to our users and experiment with different variations of the same functionality. According to the researchers at Uber, in such cases, after any successful as well as unsuccessful rolling out of any features to the users, the feature flag in the code becomes obsolete or stale. According to the developers, when a flag becomes outdated, it needs to be incapacitated in the feature flag management system. Besides, all code artefacts related to the same need should be eliminated from the source code too. These nonfunctional feature flags lead to technical issues, which in result becomes very difficult for developers to work on the codebase. Some of the drawbacks of the obsolete codes are mentioned below: Unnecessary code clutter increases the overall complexity, thus reducing the productivity of developersThe flags can stand in the way of other experimental flagsStale flags can also cause bugsThe unused code remains in the source as well as the binary To mitigate such drawbacks, Uber’s researchers developed a tool that has the ability to scan source code to delete code related to stale, or obsolete feature flags known as Piranha. According to the ride-hailing giant, the tool runs in an ongoing pipeline for the Android and iOS codebases, and the developers have used it to remove around two thousand stale feature flags and their related codes. Behind Piranha Piranha is a tool that automatically refactors code, which are related to stale flags. This tool is an automated source-to-source code refactoring tool, which is used to automatically generate differential revisions to delete code corresponding to outdated feature flags. According to developers, this tool provides excellent utility for organisations that use feature flags in their app deployments. Currently, Piranha supports Objective-C, Swift, and Java programs. PiranhaJava refactors stale feature flag-related code in Java applications, specifically those targeting the Android platform. PiranhaSwift is implemented in Swift language using SwiftSyntax for refactoring Swift code and, PiranhaObjC is used to clean up code in Objective-C programs and is implemented in C++. The developers identified three critical dimensions for performing the code cleanup, which are Code that immediately borders the feature flag APIsCode that becomes unreachable due to carrying out the above step. This step is also known as deep cleaning.Delete tests related to feature flags How It Works Piranha takes as input such as the name of the flag, the name of the flag’s author and expected treatment behaviour. It then analyses the abstract syntax trees (ASTs) of the program to generate appropriate refactorings, which are packaged into a diff or differential revisions. The diff is assigned to the author of the flag for further inspection, who can then directly commit or perform any additional refactorings before committing it. Advantages of Piranha Piranha ensures improved code hygiene and avoids technical debtThis tool automatically refactors code related to stale flagsPiranha helps from application bloating and makes it easier for the developers to work on the codebase Wrapping Up The researchers open-sourced the tool with a motive to help out other developers who are facing similar problems. Furthermore, they want to refine the code refactorings generated by Piranha and extend it to other popular languages such as Kotlin, Go, etc. Read the paper here.
World’s most extensive transportation network company, Uber has been engaged in powerful developing techniques to provide a great user experience. Uber has been using feature flags to customise the mobile app execution, which serves various features to different sets of users. These feature flags help in localising the user’s experience in different operating regions as […]
Uber’s researchers developed Piranha, a tool that automatically refactors code, which are related to stale flags.
["Uber", "Uber AI", "Uber AI labs"]
["Go", "API", "programming_languages:R", "AI", "programming_languages:Java", "GAN", "C++", "ViT", "Uber AI", "Uber", "Uber AI labs", "R", "Java"]
["AI", "R", "Go", "Java", "C++", "API", "GAN", "ViT", "programming_languages:R", "programming_languages:Java"]
A Technical Journalist who loves writing about Machine Learning and Artificial Intelligence. A lover of music, writing and learning something out of the box.