What this symbol owes: the rules that fired, and the shapes that cost.
(ir: SemanticIR, sections: readonly TwinSection[])
| 1090 | |
| 1091 | /** What this symbol owes: the rules that fired, and the shapes that cost. */ |
| 1092 | function debtRows(ir: SemanticIR, sections: readonly TwinSection[]): TwinRow[] { |
| 1093 | const risks = sections.find((section) => section.name === 'risks'); |
| 1094 | const rows: TwinRow[] = (risks?.rows ?? []).map((row) => ({ ...row, id: `debt-${row.id}` })); |
| 1095 | // Structural flags are only said when somebody measured them. This engine |
| 1096 | // reports `complexity` as unsupported for TypeScript, and a zero read off an |
| 1097 | // unsupported family is not a zero, it is a blank. |
| 1098 | if (ir.complexity.state === 'known') { |
| 1099 | const flags = ir.complexity.value; |
| 1100 | const said: string[] = []; |
| 1101 | if (flags.unguardedRecursion) { |
| 1102 | said.push(DEBT_UNGUARDED_RECURSION); |
| 1103 | } else if (flags.recursive) { |
| 1104 | said.push(DEBT_RECURSIVE); |
| 1105 | } |
| 1106 | if (flags.linearScanInLoop) { |
| 1107 | said.push(DEBT_SCAN_IN_LOOP); |
| 1108 | } |
| 1109 | if (flags.allocInLoop) { |
| 1110 | said.push(DEBT_ALLOC_IN_LOOP); |
| 1111 | } |
| 1112 | if (flags.loopDepth > 1) { |
| 1113 | said.push(debtLoopDepth(flags.loopDepth)); |
| 1114 | } |
| 1115 | if (flags.cyclomatic > 1) { |
| 1116 | said.push(debtBranches(flags.cyclomatic)); |
| 1117 | } |
| 1118 | rows.push(...said.map((label, index) => ({ |
| 1119 | id: `debt-flag-${index}`, |
| 1120 | label, |
| 1121 | factPath: 'complexity' |
| 1122 | }))); |
| 1123 | } |
| 1124 | return rows; |
| 1125 | } |
| 1126 | |
| 1127 | /** |
| 1128 | * Where this index stops, as a list a reader can count. |
no test coverage detected