Uber at this time made accessible in open supply Piranha, a device that routinely deletes stale and unused code from app codebases. The firm says it eliminates the necessity for engineers to have interaction within the job of code removing themselves, which frequently prevents them from engaged on newer options.
Concretely, Piranha might assist companies that keep apps pace up their improvement lifecycle, which in flip might minimize down on prices and enhance end-user experiences.
“At Uber, we use feature flags to customize our mobile app execution, serving different features to different sets of users. These flags allow us to, for example, localize the user’s experience in different regions where we operate and, more importantly, to gradually roll-out features to our users and experiment with different variations of the same functionality,” wrote Uber in a weblog publish. “However, after a feature has either been 100% rolled out to our users or an experimental feature has been deemed unsuccessful, the feature flag in the code becomes obsolete. These nonfunctional feature flags represent technical debt, making it difficult for developers to work on the codebase, and can bloat our apps, requiring unnecessary operations that impact performance for the end user and potentially impact overall app reliability.”
Piranha, then, scans supply code in Objective-C, Swift, and Java to delete code associated to out of date characteristic flags, in principle producing a cleaner, extra performant, and extra maintainable codebase. Uber says it runs Piranha in an ongoing pipeline for its Android and iOS codebases, and that the device has been used to take away round two thousand stale characteristic flags and associated code to this point.
Piranha takes as enter the identify of the flag, the anticipated remedy habits, and the identify of the flag’s creator. Then, it analyzes the summary syntax bushes of this system to generate refactorings (adjustments in code construction that don’t impression habits) which can be packaged into what’s known as a diff and marks code paths for deletion. The diff is assigned to the creator of the flag for additional inspection, who can commit adjustments to the grasp codebase or carry out further refactorings if needed.
Uber notes that Piranha can be utilized both as a standalone device or as a part of a pipeline. In the pipeline configuration, it queries a flag administration system for a listing of stale flags and for every gives the identify of the stale flag, its proprietor, and the supposed output habits. Piranha generates a diff and places it up in a code assessment system with the flag’s authentic creator because the default reviewer. (The creator can both settle for the diff as is, modify it as wanted, or reject and mark the flag as not being stale.) And it generates a cleanup job to trace the standing of every generated diff, with a reminder bot — PiranhaTidy — that periodically provides reminders on open Piranha-related duties.
Piranha pipelines use a heuristic to think about flags which can be unmodified within the flag administration system for greater than a selected interval (e.g., eight weeks) and to generate diffs for these flags. Individual groups liable for processing Piranha’s output diffs configure the precise time interval for staleness of a flag.
According to Uber, Piranha can course of hundreds of thousands of traces of code and takes lower than three minutes to generate a diff on common. As of at this time, it’s accessible for code that makes use of characteristic flags extensively and that has particular APIs to manage the habits of characteristic flags. “We welcome developer contributions for Piranha,” continued Uber. “Developers of all abilities are welcome, and working on the implementation of Piranha may be a great way to understand the nuances of program analysis for non-experts in the area.”