@CheckForNull
private static RuleDebt toRuleDebt(RuleDto rule, DebtModel debtModel) {
RuleDebt ruleDebt = new RuleDebt().setRuleKey(RuleKey.of(rule.getRepositoryKey(), rule.getRuleKey()));
Integer effectiveSubCharacteristicId = rule.getSubCharacteristicId() != null ? rule.getSubCharacteristicId() : rule.getDefaultSubCharacteristicId();
DebtCharacteristic subCharacteristic = (effectiveSubCharacteristicId != null && !RuleDto.DISABLED_CHARACTERISTIC_ID.equals(effectiveSubCharacteristicId)) ?
debtModel.characteristicById(effectiveSubCharacteristicId) : null;
if (subCharacteristic != null) {
ruleDebt.setSubCharacteristicKey(subCharacteristic.key());
String overriddenFunction = rule.getRemediationFunction();
String defaultFunction = rule.getDefaultRemediationFunction();
if (overriddenFunction != null) {
ruleDebt.setFunction(overriddenFunction);