Rank a tech debt register by carrying cost
Your task
Leadership wants a ranked tech debt register, and an agent builds it from signals about each module. Old or large code is not debt by itself: debt is code that keeps costing you, through changes or incidents.
Write rank_debt_register(module_records): the rule your agent follows to build the register.
module_records(list of str): one module each, written askey=valuepairs separated by;, for example"name=checkout;churn=6;complexity=30;incidents=2". The keys arename,churn(changes this quarter),complexityandincidents, in any order. All values except the name are whole numbers.- Return the names of the modules on the register, in rank order.
Rules:
- Split a record on
;, and each part at its first=. A part with no=is ignored, and so is any key other than the 4. - Drop a record that is missing any of the 4 keys, or whose name is empty.
- Drop a module whose churn and incidents are both 0: nothing about it costs you anything.
- Score each remaining module:
churn * complexity + 50 * incidents. - Return the names, highest score first. Equal scores go in ascending name order. A name that appears in two records is listed twice.
Examples
rank_debt_register(module_records: list[str]) -> list[str]Example 1
Input
rank_debt_register(["name=checkout;churn=6;complexity=30;incidents=2", "name=legacy_report;churn=0;complexity=90;incidents=0", "name=auth;churn=3;complexity=20;incidents=0"])Output
["checkout", "auth"]Example 2
Input
rank_debt_register([])Output
[]Example 3
Input
rank_debt_register(["incidents=1;name=payments;complexity=10;churn=0", "name=search;churn=2;complexity=25;incidents=0"])Output
["payments", "search"]