Package org.sonar.api.server.debt

Examples of org.sonar.api.server.debt.DebtRemediationFunction


    return changed;
  }

  private boolean mergeDebtDefinitions(RulesDefinition.Rule def, RuleDto dto, @Nullable CharacteristicDto subCharacteristic) {
    // Debt definitions are set to null if the sub-characteristic and the remediation function are null
    DebtRemediationFunction debtRemediationFunction = subCharacteristic != null ? def.debtRemediationFunction() : null;
    boolean hasDebt = subCharacteristic != null && debtRemediationFunction != null;
    if (hasDebt) {
      return mergeDebtDefinitions(def, dto,
        subCharacteristic.getId(),
        debtRemediationFunction.type().name(),
        debtRemediationFunction.coefficient(),
        debtRemediationFunction.offset(),
        def.effortToFixDescription());
    }
    return mergeDebtDefinitions(def, dto, null, null, null, null, null);
  }
View Full Code Here


      }

      if (ruleDef != null) {
        String subCharacteristicKey = ruleDef.debtSubCharacteristic();
        CharacteristicDto subCharacteristicDto = characteristicByKey(subCharacteristicKey, allCharacteristicDtos, false);
        DebtRemediationFunction remediationFunction = ruleDef.debtRemediationFunction();
        boolean hasDebtDefinition = subCharacteristicDto != null && remediationFunction != null;

        rule.setDefaultSubCharacteristicId(hasDebtDefinition ? subCharacteristicDto.getId() : null);
        rule.setDefaultRemediationFunction(hasDebtDefinition ? remediationFunction.type().name() : null);
        rule.setDefaultRemediationCoefficient(hasDebtDefinition ? remediationFunction.coefficient() : null);
        rule.setDefaultRemediationOffset(hasDebtDefinition ? remediationFunction.offset() : null);
      }

      // Reset overridden debt definitions
      rule.setSubCharacteristicId(null);
      rule.setRemediationFunction(null);
View Full Code Here

  private void updateDebtRemediationFunction(RuleUpdate update, Context context) {
    boolean noChar =
      (context.rule.getDefaultSubCharacteristicId() == null && context.rule.getSubCharacteristicId() == null) ||
        (context.rule.getSubCharacteristicId() != null && context.rule.getSubCharacteristicId().intValue() == RuleDto.DISABLED_CHARACTERISTIC_ID);

    DebtRemediationFunction function = update.getDebtRemediationFunction();
    if (noChar || function == null) {
      context.rule.setRemediationFunction(null);
      context.rule.setRemediationCoefficient(null);
      context.rule.setRemediationOffset(null);
    } else {
      if (isSameAsDefaultFunction(function, context.rule)) {
        // reset to default
        context.rule.setRemediationFunction(null);
        context.rule.setRemediationCoefficient(null);
        context.rule.setRemediationOffset(null);
      } else {
        context.rule.setRemediationFunction(function.type().name());
        context.rule.setRemediationCoefficient(function.coefficient());
        context.rule.setRemediationOffset(function.offset());
      }
    }
  }
View Full Code Here

    value = request.param(PARAM_DEBT_REMEDIATION_FN_TYPE);
    if (value != null) {
      if (StringUtils.isBlank(value)) {
        update.setDebtRemediationFunction(null);
      } else {
        DebtRemediationFunction fn = new DefaultDebtRemediationFunction(
          DebtRemediationFunction.Type.valueOf(value), request.param(PARAM_DEBT_REMEDIATION_FY_COEFF),
          request.param(PARAM_DEBT_REMEDIATION_FN_OFFSET));
        update.setDebtRemediationFunction(fn);
      }
    }
View Full Code Here

    }
    final String function = getNullableField(RuleNormalizer.RuleField.DEBT_FUNCTION_TYPE.field());
    if (function == null || function.isEmpty()) {
      return defaultDebtRemediationFunction();
    } else {
      return new DebtRemediationFunction() {
        @Override
        public Type type() {
          return Type.valueOf(function.toUpperCase());
        }
View Full Code Here

  public DebtRemediationFunction defaultDebtRemediationFunction() {
    final String function = getNullableField(RuleNormalizer.RuleField.DEFAULT_DEBT_FUNCTION_TYPE.field());
    if (function == null || function.isEmpty()) {
      return null;
    } else {
      return new DebtRemediationFunction() {
        @Override
        public Type type() {
          return Type.valueOf(function.toUpperCase());
        }
View Full Code Here

TOP

Related Classes of org.sonar.api.server.debt.DebtRemediationFunction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.