A command-line tool for cleaning up stale feature flags in Kotlin projects.
Ensure you have Python 3.12 installed. Clone the repository and install dependencies:
git clone https://github.com/duckduckgo/Android.git
cd <path/to>/Android/scripts/piranha
pip install -r requirements.txt- Python 3.12
- Dependencies listed in
requirements.txt
Windows:
- Download Python 3.12 (https://www.python.org/downloads/release/python-3120/) and install it
Linux:
sudo apt update
sudo apt install python3.12 python3.12-venvMacOS:
brew install python@3.12Windows:
py -3.12 -m venv myenvMacOS/Linux:
python3.12 -m venv myenvWindows:
myenv\Scripts\activateMacOS/Linux
source myenv/bin/activatepython --versionpython clean.py [-h] -r ROOT_PATH -c CONFIGURATION_PATH -f FLAGS [FLAGS ...]-
-h, --help
Show this help message and exit. -
-r ROOT_PATH, --root-path ROOT_PATH
Root path for searching Kotlin files. -
-c CONFIGURATION_PATH, --configuration-path CONFIGURATION_PATH
Path for the configuration files. -
-f FLAGS [FLAGS ...], --flags FLAGS [FLAGS ...]
Space-separated list of flag configurations in the format:
flagname:treated_value(e.g.,'flag1:true flag2:false').
configuration-path: Path to therules.tomlfile containing cleanup rules.root-path: The root path of your Android project.
Assuming you're in the Android project folder, you can run:
python scripts/piranha/clean.py -r . -c scripts/piranha/configurations/ -f screenLock:false optimizeTrackerEvaluationV2:trueThis command runs the cleanup tool in the current directory (.), using the configuration files from scripts/piranha/configurations/ and applying the flag transformations provided.
- The script modifies Kotlin files based on the given flag configurations.
- Use carefully, as it may remove or alter code.

